Forums

[resolved] Mage enabler phtml inclusion variable scope (2 posts)

  1. wcrain
    Member
    Posted 1 year ago #

    Referencing magento phtml files in a static fashion from WordPress instance works fine but looking to keep the variable scope intact (e.g., showing the cart phtml within WordPress and retaining the values for cart count, etc..).

    In the cart phtml:

    $_cartQty = $this->getSummaryCount()

    Is there a way to keep $_cartQty and the rest of the variables used within the phtml intact when called into WordPress? Or is the best/only option to access those values via Mage::getSingleton/Mage::helper and re-declaring those same variables in order to recreate the needed phtml files in WordPress? The goal is to avoid maintaining two virtually identical cart header pieces.

  2. wcrain
    Member
    Posted 1 year ago #

    just needed to use the following - phtml and all variables including cart qty now showing as expected:

    $mycartBlock = $app->getLayout()->getBlockSingleton( 'checkout/cart_sidebar')->setTemplate("checkout/cart/cartheader.phtml")->toHtml();

Topic Closed

This topic has been closed to new replies.

About this Topic