将产品添加到购物车后如何获取报价项目ID? [英] How to get Quote Item Id after adding a product to cart?

查看:105
本文介绍了将产品添加到购物车后如何获取报价项目ID?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

每次将商品添加到购物车时,我都希望引用商品ID.我尝试了很多事件,它们返回了报价项目对象,但是该对象不包含报价项目ID,因为它仅在购物车保存到数据库时才存在.那么是否有任何事件会返回带有报价项目ID的报价项目对象?

I want quote item id every time a product added to cart. I have tried many event they return the quote item object but object doesn't contain quote item id as it exists only when cart save to the db. So is there any event which will return the quote item object with quote item id?

我已经使用了以下事件

checkout_cart_product_add_after
sales_quote_add_item

,但不会返回

public function addItemToSalesModelInfo(Varien_Event_Observer $observer){
    $item = $observer->getEvent()->getQuoteItem();
}

推荐答案

您正在使用正确的事件,即

You are using a correct event i.e.

checkout_cart_product_add_after

要访问报价项目ID,您需要使用

to access quote item id, you need to use,

$item = $observer->getQuoteItem()

您可以访问所有报价项目信息,例如

you can access all quote item info like

$item->getProductId()等.

这篇关于将产品添加到购物车后如何获取报价项目ID?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆