[英]how do I get product data when adding to cart and listening for the “checkout_cart_product_add_after” event
I am a developer stuck on an interesting problem, I am trying to retrieve the stock data for a simple product as it is added to the cart. 我是一个陷入一个有趣问题的开发人员,我正尝试检索添加到购物车中的简单产品的库存数据。 The simple product is added from the product page of a configurable product.
简单产品是从可配置产品的产品页面添加的。 When I look at the properties of $observer->getEvent()->getProduct(), it appears as though the product data is that of the configurable product and not the simple product, which makes no sense to me.
当我查看$ observer-> getEvent()-> getProduct()的属性时,似乎产品数据是可配置产品的数据,而不是简单产品的数据,这对我来说毫无意义。 Any suggestions?
有什么建议么?
This is just what runs through my mind but there might be more elegant ways: 这就是我的想法,但是可能会有更优雅的方式:
$productId = $configurableProduct->getOptionByCode('simple_product')->getProductId();
$simple = Mage::getModel('catalog/product')->load($productId);
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.