By In Magento

Extending CreareSEO module

CreareSEO module is really great addition to any Magento 1 store and helps a lot with basic SEO related settings, latest version can be found on GitHub. Among bunch of useful features there is also a ‘Twitter Cards and Open Graph’ section that will automatically add Twitter card and OG meta tags to product details page.

In few simple steps we will extend that feature to category page as well.

First we will add one more filed in section ‘Twitter Cards and Open Graph’ that we will use for Facebook app ID. Open in editor file: app/code/community/Creare/CreareSeoCore/etc/system.xml
and add code from attached file ‘system-update’. Be sure to copy code within section, we want to keep module consistency and usability.

Save file and open Magento admin: System->CreareSEO->General Settings tab, you will see a new field that we named ‘Facebook app id‘. Enter your Facebook app id and hit save button.

On our luck CreareSEO use base package and default theme so it is easy to find and edit layout files.
So next would be XML layout file:
app/design/frontend/base/default/layout/creareseo.xml

We will add this line:

< block type="core/template" name="ccreareseo.category.social" ifconfig="creareseocore/social/enabled" template="creareseo/social/category-social.phtml" />

For sections (for both sections reference is ‘head’):
catalog_category_layered
and:
catalog_category_view

After that we will create a template file by name ‘category-social.phtml’ and copy it into folder:
app/design/frontend/base/default/template/creareseo/social/

To save you some time I will provide template with code. Since code in template is quite simple so there is no need to explain it line by line. Of course code can be changed as it suit you and additional marks can be added. If you find something interesting you are more than welcome to shear it in comments 🙂

 

Finally we will use Facebook app ID on product details template too (it is missing for some reason), open template:
app/design/frontend/base/default/template/creareseo/social/social.phtml

and add this line:
< meta property=”fb:app_id” content=”< ? php echo Mage::getStoreConfig(‘creareseocore/social/facebookappid’) ? >” />

Once you save everything, clear Magento cache and test your page using official FB tool:
https://developers.facebook.com/tools/debug/

Leave a Reply

Your email address will not be published. Required fields are marked *