Php 在购物车页面获取产品属性值,该值在产品详细信息页面更改
我正在开发一个扩展。 我已在后端创建属性并将其分配给产品。 我在添加到购物车时更改了该产品属性,并且在结帐/购物车页面上获取相同的值,但在结帐/购物车页面上无法获取相同的值Php 在购物车页面获取产品属性值,该值在产品详细信息页面更改,php,magento,Php,Magento,我正在开发一个扩展。 我已在后端创建属性并将其分配给产品。 我在添加到购物车时更改了该产品属性,并且在结帐/购物车页面上获取相同的值,但在结帐/购物车页面上无法获取相同的值 $cartQuote = Mage::getModel('checkout/cart')->getQuote()->getAllVisibleItems(); foreach ($cartQuote as $item) { $productId = $item->ge
$cartQuote = Mage::getModel('checkout/cart')->getQuote()->getAllVisibleItems();
foreach ($cartQuote as $item) {
$productId = $item->getProduct()->getId();
$productPrice = $item->getProduct()->getPrice();
$item->getProduct()->getCanImage();//I can get my value here
}
我将此产品价值存储在结帐/购物车模型中,如下所示:
//saving product to cart
$product_id = Mage::app()->getRequest()->getPost('id');
$qty = Mage::app()->getRequest()->getPost('qty');
$product = Mage::getModel('catalog/product')->load($product_id);
$product->setCanImage('wasdwasdwasd');
$cart = Mage::getModel('checkout/cart');
$cart->init();
$cart->addProduct($product, array('qty' => $qty));
$cart->save();
Mage::getSingleton('checkout/session')->setCartWasUpdated(true);
Mage::getSingleton('core/session')->addSuccess('Product added successfully');
我可以像下面的代码一样在同一个页面上检索属性值,但我无法在checkout/cart页面上获取它
$cartQuote = Mage::getModel('checkout/cart')->getQuote()->getAllVisibleItems();
foreach ($cartQuote as $item) {
$productId = $item->getProduct()->getId();
$productPrice = $item->getProduct()->getPrice();
$item->getProduct()->getCanImage();//I can get my value here
}
我使用了上面相同的代码,但我并没有从结帐/购物车报价中获得价值
我不想将这个值存储在数据库中,因为如果很多用户动态添加这个产品,这会带来麻烦,所以我认为quote是保存产品数据的好地方
请给我建议解决办法