简体   繁体   中英

Magento sidebar will not show cart quantity

I'm trying to show the right sidebar of my Magento shopping cart in an external PHP file. I was able to get that file to show the sidebar, but for some reason the sidebar is not showing the correct information with regards to the items in the cart. If I have any items in my cart, it will still say “you have no items in your cart”. If I modify sidebar.phtml to echo the $_cartQty = $this->getSummaryCount() function, it just displays nothing. Not even 0 . Your help would be greatly appreciated!

My code of calling sidebar.phtml :

<?php
require_once 'app/Mage.php';
umask(0);
Mage::app()->loadArea('frontend');
Mage::app()->setCurrentStore(6);

$layout = Mage::getSingleton('core/layout');

//load default xml layout handle and generate blocks
$layout->getUpdate()->load('default');
$layout->generateXml()->generateBlocks();

//get the loaded head and header blocks and output
$headBlock = $layout->getBlock('right');
$headerBlock = $layout->getBlock('cart_sidebar');
echo $headBlock->toHtml() . $headerBlock->toHtml();

The sidebar.phtml is just a default 1.7.2 file, so that should be straightforward.

I found the solution that worked at this website -- totally awesome! http://www.codeoncall.com/get-shopping-cart-quantity-outside-of-magento/

Thanks for all those who looked at this, and I hope it will help someone in the future.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM