trustpilot / plugin-magento1

Magento 1 plugin for sending invitation data to Trustpilot & adding TrustBoxes
MIT License
0 stars 3 forks source link

Trustbox Array not working at all! #1

Closed IbrahimS2 closed 5 years ago

IbrahimS2 commented 5 years ago

The Trustbox does not iterate as it should be, and it does not show up on the product page even after publishing the Trustbox from the backend!

public function loadTrustboxes()
    {
        $settings = json_decode($this->_helper->getConfig('master_settings_field'))->trustbox;
        if ($settings->trustboxes) {
            $currentUrl = Mage::helper('core/url')->getCurrentUrl();
            $homePageId = Mage::getStoreConfig(Mage_Cms_Helper_Page::XML_PATH_HOME_PAGE);
            $loadedTrustboxes = $this->loadPageTrustboxes($settings, $currentUrl);

            if (Mage::registry('current_product')) {
                $loadedTrustboxes = array_merge((array)$this->loadPageTrustboxes($settings, 'product'), (array)$loadedTrustboxes);
            }
            else if (Mage::registry('current_category')) {
                $loadedTrustboxes = array_merge((array)$this->loadPageTrustboxes($settings, 'category'), (array)$loadedTrustboxes);
                var_dump($loadedTrustboxes);
            }
            if (Mage::getBlockSingleton('page/html_header')->getIsHomePage() ||
                    Mage::getSingleton('cms/page')->getIdentifier() == $homePageId) {
                $loadedTrustboxes = array_merge((array)$this->loadPageTrustboxes($settings, 'landing'), (array)$loadedTrustboxes);
            }

            if (count($loadedTrustboxes) > 0) {
                $settings->trustboxes = $loadedTrustboxes;
                return json_encode($settings, JSON_HEX_APOS);
            }
        }

        return '{"trustboxes":[]}';
    }

Console Logs

IbrahimS2 commented 5 years ago

Attached the console log of "trustpilot_trustbox_settings" variable 1555481055042.log

It seems as if there is no more than one product in the array to begin with!?

vdabar commented 5 years ago

Hey, it should be fixed with this update: https://github.com/trustpilot/plugin-magento1/commit/45cb86dea1c4d6887a9c08a545838a94b04c48a9