AbanteCart Development > Development Help Needed

(Solved) How to set blurb as meta description



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: ---<?php if ($description) { ?>
<meta name="description" content="<?php echo $description; ?>" />
<?php } elseif ($blurb) { ?>
<meta name="description" content="<?php echo $blurb; ?>" />
<?php } ?>
--- End code ---

2) Add a call to getBlurb() method at line 38 of head.php:

--- Code: --- $this->view->assign('description', $this->document->getDescription());
$this->view->assign('blurb', $this->document->getBlurb());
--- End code ---

3) Create a private variable $blurb, as well as setBlurb() and getBlurb() functions (i.e. methods) in document.php:

--- Code: --- private $blurb;
--- End code ---

--- Code: --- public function setBlurb($blurb){
$this->blurb = $blurb;

--- End code ---

--- Code: --- public function getBlurb(){
return $this->blurb;
--- End code ---

4) At line 157 of 'storefront/controller/pages/product/product.tpl', call setBlurb() right after the call that sets the meta_description.

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.

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.



[0] Message Index

Go to full version
Powered by SMFPacks Social Login Mod