Posting in the Magento forums has been disabled pending the implementation of a new and improved forum solution which should better serve the community.

For new questions please post at magento.stackexchange.com, the community-run support site for the Magento community. We will be providing updates on the new forum solution soon. For questions or concerns please email community@magento.com.

Magento Forum

Magento Crashes
 
nplanet
Member
 
Avatar
Total Posts:  31
Joined:  2008-11-19
 

Hello All,

I am trying to get MyCart’s quantity in the Header. (I am not using toplink functionaltiy as that is adding many unwanted items.)

For this I found the following code:

<? if(Mage::getSingleton('checkout/session')->getQuote()->getItemsSummaryQty() > 0{ ?>
<?
=__(Mage::getSingleton('checkout/session')->getQuote()->getItemsSummaryQty())?> 
<? } 
else { ?>

<? } ?>

Posted by marcfalk in thread: http://www.magentocommerce.com/boards/viewthread/26443/

But the moment I paste this code and reload web page Magento Crashes with following Dump:

Warningarray_key_exists() [function.array-key-exists]The first argument should be either a string or an integer  in C:\xampp\htdocs\edmegastore\app\code\core\Mage\Core\Model\Translate.php on line 546
Trace
:
#0 C:\xampp\htdocs\edmegastore\app\code\core\Mage\Core\Model\Translate.php(546): mageCoreErrorHandler(2, 'array_key_exist...', 'C:\xampp\htdocs...', 546, Array)
#1 C:\xampp\htdocs\edmegastore\app\code\core\Mage\Core\Model\Translate.php(387): Mage_Core_Model_Translate->_getTranslatedString(207, Array)
#2 C:\xampp\htdocs\edmegastore\app\code\core\Mage\Core\functions.php(106): Mage_Core_Model_Translate->translate(207, 'frontend/defaul...')
#3 C:\xampp\htdocs\edmegastore\app\design\frontend\Edmegastore\Edmegastore\template\page\html\header.phtml(58): __()
#4 C:\xampp\htdocs\edmegastore\app\code\core\Mage\Core\Block\Template.php(144): include('C:\xampp\htdocs...')
#5 C:\xampp\htdocs\edmegastore\app\code\core\Mage\Core\Block\Template.php(176): Mage_Core_Block_Template->fetchView(Array)
#6 C:\xampp\htdocs\edmegastore\app\code\core\Mage\Core\Block\Template.php(193): Mage_Core_Block_Template->renderView(207)
#7 C:\xampp\htdocs\edmegastore\app\code\core\Mage\Core\Block\Abstract.php(643): Mage_Core_Block_Template->_toHtml('frontend\Edmega...')
#8 C:\xampp\htdocs\edmegastore\app\code\core\Mage\Core\Block\Abstract.php(503): Mage_Core_Block_Abstract->toHtml()
#9 C:\xampp\htdocs\edmegastore\app\code\core\Mage\Core\Block\Abstract.php(454): Mage_Core_Block_Abstract->_getChildHtml()
#10 C:\xampp\htdocs\edmegastore\app\design\frontend\Edmegastore\Edmegastore\template\page\2columns-left.phtml(42): Mage_Core_Block_Abstract->getChildHtml()
#11 C:\xampp\htdocs\edmegastore\app\code\core\Mage\Core\Block\Template.php(144): include('C:\xampp\htdocs...')
#12 C:\xampp\htdocs\edmegastore\app\code\core\Mage\Core\Block\Template.php(176): Mage_Core_Block_Template->fetchView('header', true)
#13 C:\xampp\htdocs\edmegastore\app\code\core\Mage\Core\Block\Template.php(193): Mage_Core_Block_Template->renderView('header')
#14 C:\xampp\htdocs\edmegastore\app\code\core\Mage\Core\Block\Abstract.php(643): Mage_Core_Block_Template->_toHtml('frontend\Edmega...')
#15 C:\xampp\htdocs\edmegastore\app\code\core\Mage\Core\Model\Layout.php(525): Mage_Core_Block_Abstract->toHtml()
#16 C:\xampp\htdocs\edmegastore\app\code\core\Mage\Core\Controller\Varien\Action.php(326): Mage_Core_Model_Layout->getOutput()
#17 C:\xampp\htdocs\edmegastore\app\code\core\Mage\Cms\Helper\Page.php(92): Mage_Core_Controller_Varien_Action->renderLayout()
#18 C:\xampp\htdocs\edmegastore\app\code\core\Mage\Cms\controllers\IndexController.php(32): Mage_Cms_Helper_Page->renderPage()
#19 C:\xampp\htdocs\edmegastore\app\code\core\Mage\Core\Controller\Varien\Action.php(349): Mage_Cms_IndexController->indexAction()
#20 C:\xampp\htdocs\edmegastore\app\code\core\Mage\Core\Controller\Varien\Router\Standard.php(163): Mage_Core_Controller_Varien_Action->dispatch(Object(Mage_Cms_IndexController), 'Edmegastore')
#21 C:\xampp\htdocs\edmegastore\app\code\core\Mage\Core\Controller\Varien\Front.php(174): Mage_Core_Controller_Varien_Router_Standard->match()
#22 C:\xampp\htdocs\edmegastore\app\Mage.php(447): Mage_Core_Controller_Varien_Front->dispatch('index')
#23 C:\xampp\htdocs\edmegastore\index.php(52): Mage::run(Object(Mage_Core_Controller_Request_Http))
#24 {main}

- What must be wrong here?
- How can I solve this problem?

Thanks in Advance,

NPlanet

 
Magento Community Magento Community
Magento Community
Magento Community
 
mzentrale1
Guru
 
Total Posts:  731
Joined:  2007-12-06
Stuttgart, Germany
 

Hi,

<? if(Mage::getSingleton('checkout/session')->getQuote()->getItemsSummaryQty() > 0): ?>
<?
Mage::getSingleton('checkout/session')->getQuote()->getItemsSummaryQty() ?> 
<? 
else; ?>

<? 
endif;?>

cheers

 
Magento Community Magento Community
Magento Community
Magento Community
 
nplanet
Member
 
Avatar
Total Posts:  31
Joined:  2008-11-19
 

Thanks for solving this problem.

Regards,

 
Magento Community Magento Community
Magento Community
Magento Community
Magento Community
Magento Community
Back to top