I am playing around with the Mini Cart content from outside of Magento.

This section of code uses $this:

<?php foreach($cartItems as $_item): ?>
    <?php echo $this->getItemHtml($_item) ?>
<?php endforeach; ?>

get_class($this) tells me that it is using Mage_Checkout_Block_Cart_Sidebar

How can I access this?

For example I know you can replace $this with Mage::helper('checkout/cart'), is there an equivalent for Mage_Checkout_Block_Cart_Sidebar?


but this may not work in this case because item rendering requires a set of renderers attached to the main block.

  • Genius. Thank you! – Lee Sep 5 '16 at 11:13

Though its not god way But you can use outside you can create object via below code and you can use it.

$class = Mage::app()->getLayout()->createBlock('checkout/cart_sidebar');
  • you should never instantiate classes using new. Specially blocks. Blocks need to have a layout instance associated to them. – Marius Sep 5 '16 at 11:07
  • Ok I will update My answer – Murtuza Zabuawala Sep 5 '16 at 11:10

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.