Skip to content

Make product_catalog_id optional #3

@JEreth

Description

@JEreth

In some scenarios a product_catalog_id is not neceassary. However, if it is not added in admin it breaks the tracking code since there is an empty value in frontend a la ''product_catalog_id: }"

Better check if catalog_id is set before adding it to the tacking code. This can be done by moving it to a extra function like that:
protected function getProductCatalogId() { return (Mage::helper('hevelop_facebookpixel')->getProductCatalogId()!='') ? "', product_catalog_id: " . Mage::helper('hevelop_facebookpixel')->getProductCatalogId() : ''; }

And call it in the code function like that:

$pixelCat = "fbq('track', 'ViewContent', {content_category: '" . addslashes($currCat->getName()) . "', content_ids: ['" . implode("','", $productIds) . "'], content_type: 'product'". $this->getProductCatalogId() . "});";

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions