[英]Magento - Trying to get custom product attribute
I have custom product attribute for every product in my store. 我对商店中的每个产品都有自定义产品属性。 The attribute code is
product_link
. 属性代码为
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. 但是我无法获得所有产品具有的
product_link
属性中的链接值。
Where is my mistake how may i fix it? 我的错误在哪里,我该如何解决?
就那么简单:
$ProductLink = Mage::getModel('catalog/product')->load($item->getProduct()->getId())->getProductLink();
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.