1

Inexperienced with Magento, I am having trouble with a footer script that I am extending, which appears to be evaluating twice. I've confirmed that it's running twice by logging each run through. I'm not sure why this is happening in the first place and haven't found any similar questions on here.

Interestingly, I'm loading a product's page and I can see that

Mage::registry('current_product')

will initially empty and on the second run through, the product appears to be loaded. My problem with this is that I have some front-end stuff I'm trying to build out that is dependent on the product being available.

I'd be happy to provide any more info that would be helpful.

Does anyone have any idea why this footer script is running twice?

It has been added as a reference, in the XML that contains all other components, once.

Footer Script loading in local.xml

<reference name="before_body_end">
<block type="core/template" name="footer.theme.scripts" template="page/html/footer_theme_scripts.phtml" before="-" />
</reference>

Part of my footer theme script:

    <?php
/**
 * Additional scripts
 */
?>

<?php
    //Get grid configuration array
    $theme = $this->helper('ultimo');
    $gc = $theme->getCfgGroup('category_grid');

if (Mage::registry('current_product')) {
            if (empty($_product)) {
                $_product = Mage::registry('current_product');
            }

            if ($_product->getVendorSku() != NULL) {
                $agil_one->setProductId($_product->getData('vendor_sku'));
                $agil_one->setCategoryHex($_product->getData('vendor_sku'));
            } else {
                error_log('Vendor Sku is NULL. Is there a product? ' . $_product);
                return; // return if on product page but there is no product available
            }
        }

?>
4
  • 3
    Please add your xml and footer code as well. – Adarsh Khatri Feb 22 '16 at 22:56
  • Hey @AdarshKhatri, I added portions of both, hopefully this helps clarify things. I know the footer theme script is evaluated twice because any logging will be printed twice. – jackie Feb 23 '16 at 14:20
  • Any ideas? Still spinning wheels here – jackie Feb 24 '16 at 15:43
  • Can you also add your rendered html screenshot? – Adarsh Khatri Mar 3 '16 at 0:31
1

I would recommend a standard use of xml layout logging (adapted from Alan Storm I believe...)

            $oRequest  = Mage::app()->getRequest();
            $info = sprintf(
                "\nRequest: %s\nFull Action Name: %s_%s_%s\nHandles:\n\t%s\nUpdate XML:\n%s",
                $oRequest->getRouteName(),
                $oRequest->getRequestedRouteName(),      //full action name 1/3
                $oRequest->getRequestedControllerName(), //full action name 2/3
                $oRequest->getRequestedActionName(),     //full action name 3/3
                implode( "\n\t", Mage::app()->getLayout()->getUpdate()->getHandles() ),
                Mage::app()->getLayout()->getUpdate()->asString()
            );
            // Force logging to var/log/layout.log
            Mage::log($info, Zend_Log::INFO, 'layout.log', true);

Logs xml layout for a particular route into a logfile.

Check the log file after performing a page load to find where the footer xml is loaded twice. If possible attach the output(relevant portions) and I can assist further.

1

Possibly some one else is calling this from xml / template file .. can you try finding / grep footer_theme_scripts.phtml in your entire design folder , and remove the additional entries .. ?

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.