Author Topic: (Solved) How to set blurb as meta description  (Read 560 times)

Offline OneMore

  • Newbie
  • *
  • Posts: 46
  • Karma: +12/-0
    • View Profile
(Solved) How to set blurb as meta description
« on: February 24, 2024, 02:22:13 PM »
Hi,

Here is how you can set the blurb as content for <meta name="description" > on your product pages when there is no meta_description set.
Tested as working with AbanteCart 1.2.11.

1)
Edit head.tpl and add the "elseif" clause as follows.
Code: [Select]
<?php if ($description) { ?>
<meta name="description" content="<?php echo $description?>" />
<?php } elseif ($blurb) { ?>
<meta name="description" content="<?php echo $blurb?>" />
<?php ?>

2) Add a call to getBlurb() method at line 38 of head.php:
Code: [Select]
$this->view->assign('description', $this->document->getDescription());
$this->view->assign('blurb', $this->document->getBlurb());

3) Create a private variable $blurb, as well as setBlurb() and getBlurb() functions (i.e. methods) in document.php:
Code: [Select]
private $blurb;
Code: [Select]
public function setBlurb($blurb){
$this->blurb = $blurb;
}
Code: [Select]
public function getBlurb(){
return $this->blurb;
}

4) At line 157 of 'storefront/controller/pages/product/product.tpl', call setBlurb() right after the call that sets the meta_description.
      $this->document->setDescription($product_info['meta_description']);
      $this->document->setBlurb($product_info['blurb']);
« Last Edit: February 25, 2024, 05:58:51 AM by OneMore »

Offline fanteamgear

  • Newbie
  • *
  • Posts: 7
  • Karma: +1/-0
    • View Profile
    • wishbargains.com
Re: How to set blurb as meta description?
« Reply #1 on: February 24, 2024, 11:18:14 PM »
If you have access to your DB, you can write an external file to query what you need directly from the database from product_descriptions table and simply use include 'your metatag file'; in the head of the document. It works faster than having to pine through Abantecart or modify core files and process which may be overridden when you do an update.  Contact me if you still need help with this.

Offline OneMore

  • Newbie
  • *
  • Posts: 46
  • Karma: +12/-0
    • View Profile
Re: (Solved) How to set blurb as meta description
« Reply #2 on: February 25, 2024, 06:04:23 AM »
Thank you fanteamgear.
I have access to the database, but decided to further explore how AbanteCart was getting the value of "meta_description", in order to not create additional database connection and query for a single field.

As in "product_description", AbanteCart was able to extract the value "meta_description", I searched for that string.
The missing part, was adding "$this->document->setBlurb($product_info['blurb']);" in product.tpl.
I edited my original post, so that everyone can benefit from the procedure.

Cheers.

 

Powered by SMFPacks Social Login Mod