[英]How to get a particular item from the cart using the item id in cart?
我想使用购物车中的商品ID(而非商品ID)从购物车中获取特定商品。
http://localhost/magento81/index.php/checkout/cart/configure/id/1/
我想使用此ID, ID / 1加载
如何获得?
$cart = Mage::getModel('checkout/cart')->getQuote();
foreach ($cart->getAllItems() as $item) {
if($item->getId() == 1)
{
$productId = $item->getProduct()->getId();
$productPrice = $item->getProduct()->getPrice();
}
}
通常,如果您使用print_r($ item-> getProduct()-> getData()),它将显示购物车中与产品相关的所有信息。
$ this应该可以解决问题。
$itemId = 1;
$item = Mage::getModel('sales/quote_item')->load($itemId);
如果要获取与该商品关联的产品对象,请继续此操作
$product = $item->getProduct();
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.