开发者

Trouble with getting magento attributes while checkout

开发者 https://www.devze.com 2023-03-25 08:11 出处:网络
Help pls with getting magento attribute while checkbout. I have \'only_registered\' at开发者_如何学Ctribute. I trying to get attribute via this code:

Help pls with getting magento attribute while checkbout. I have 'only_registered' at开发者_如何学Ctribute. I trying to get attribute via this code:

$cart = Mage::getSingleton('checkout/session')->getQuote()->getAllVisibleItems();
foreach ($cart as $_item){
  $_product = Mage::getModel('catalog/product')->load($_item->getProduct());
  $registeredonly = $_product->getRegisteredOnly();
}

but this code generate magento error.

Syntax error or access violation: 1064 You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near ')' at line 1";i:1;s:4723:"#0 /work/www/topps.loc/lib/Zend/Db/Statement.php(300): Zend_Db_Statement_Pdo->_execute(Array)


I could see the following error in code:

$_product = Mage::getModel('catalog/product')->load($_item->getProduct());

Should be:

$_product = Mage::getModel('catalog/product')->load($_item->getProductId());

And I see you said the variable name to be 'only_registered' so you should access it by:

$registeredonly = $_product->getOnlyRegistered();

And if that doesn't works simply do:

$registeredonly = $_product->getData('only_registered');
0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号