I have custom product attribute for every product in my store. The attribute code is product_link
.
I have this code to get all products in the current cart session:
<?php
error_reporting(E_ALL | E_STRICT);
$mageFilename = 'app/Mage.php';
require_once $mageFilename;
$app = Mage::app('default');
Mage::app();
Mage::getSingleton('core/session', array('name' => 'frontend'));
$cart = Mage::getModel('checkout/cart')->getQuote();
foreach ($cart->getAllItems() as $item) {
$ProductLink = $item->getProduct()->getProductLink();
$ProductName = $item->getProduct()->getName();
echo "ProductLink: $ProductLink - ProductName: $ProductName<br>";
}
I have no problem to get the name of the product which is a default attribute. However i can not get the link value in product_link
attribute which all products have.
Where is my mistake how may i fix it?
就那么简单:
$ProductLink = Mage::getModel('catalog/product')->load($item->getProduct()->getId())->getProductLink();
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.