产品和报价项目之间的概念区别是什么

发布于 2024-08-23 11:54:13 字数 255 浏览 5 评论 0原文

涉及的类:Mage_Sales_Model_Quote_ItemMage_Catalog_Model_Product

我通过监听事件(在购物车添加上)得到了它们。我正在尝试从外部来源更新产品的数量信息。

到目前为止,我的代码仅基于产品信息,我不确定这是否正确。

报价项目的目的是什么? 捆绑可配置产品怎么样?您对如何从捆绑产品中获取单个项目有什么建议吗?

谢谢

Involved classes : Mage_Sales_Model_Quote_Item and Mage_Catalog_Model_Product.

I get both of them as a result of listening an event ( on cart add ). I am trying to update the quantity information for a product from an external source.

So far I based my code only on the product information and I am not sure if this is correct.

What is the purpose of Quote Items?
How about an bundled of configurable product? Do you have any recommendation on how to get the individual items from a bundle product?

Thanks

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(3

夕嗳→ 2024-08-30 11:54:13

我要感谢两位回应者迄今为止所做的努力,但他们的回应与我的问题相去甚远。我会根据我所学到的知识尝试做出回应。

报价是一个与订单相关的概念,只是在Magento的工作流程中它先于订单。现实世界的概念类似于预购,就像一张便利贴,您可以在上面将您在餐厅购买的菜肴放在上面,而不需要订单或账单。

我正在监视一个向我发送 $product 和 $orderItem 的事件 (checkout_cart_product_add_after)。我现在明白,发送这两个信息是为了获取有关产品的信息以及有关计费的信息以及该产品在未来订单中的表示。

在分组产品的情况下,例如 $product 是具有各种关联尺寸的 T 恤,$product 将包含主分组产品的 SKU,$orderItem 将包含所选 T 恤的实例(中号 SKU) )。

仅供参考:因此,为了更新购物车更新中的产品信息,如果 $item 是复杂类型(捆绑、可配置或分组),则最好从 $item 获取产品信息

I want to thank both responders so far for their effort but their responses are pretty far from my question. I'll try to respond myself based on the things that I've learned.

A quote is a concept related to the order, only that is previous to that in terms of work flow in Magento. A real world concept is something like a preorder, like a postIt on which you place your asked dishes in a restaurant without being an order or a bill.

I was monitoring an event (checkout_cart_product_add_after) that is sending me the $product and the $orderItem. I understand now that is sending both in order to get information about the product and information about billing and the representation of that product in the future order.

In the case of the grouped products for example where the $product is Tshirt with various associated sizes, the $product will contain the SKU of the main grouped product and the $orderItem will contain the instance of the Tshirt that was selected ( medium size SKU ).

FYI: So in order to update the information of a product at cart update you have is better to get the product info from the $item if is a complex type ( bundle, configurable or grouped )

荭秂 2024-08-30 11:54:13

具体来说,Magento 将报价项目放入购物车。这些报价项目是使用 $product->prepareForCart 检索的。这些项目还包括不同的信息,例如数量和可配置的产品选项(在报价项目上)。

从后端角度来看,产品数据存储在:catalog_product_entity_* 中,而报价项目存储在 sales_flat_quote_item 中(至少在 Enterprise 中。其他人可能想在社区)。


编辑:附上我们不久前编写的一些用于导入产品库存的代码。

$product                 = Mage::getModel("catalog/product")->load($productId);
$product->seStockData(array(
    "qty"                         => (int)$yourQuantity,
    "is_in_stock"                 => ((int)$isTheProductInStock),
    "manage_stock"                => $manageStock,
    "is_qty_decimal"              => $isQtyDecimal,
    "use_config_manage_stock"     => $useConfigManageStock,
));

Mage::getModel('catalog/product_api')->update($sku,$product->getData());

出于您的目的,您可能只需要调用 $product->save();,但我包含了编写的整个代码段,因为它有效。

希望有帮助。谢谢,

Magento drops quote items into the cart, specifically. Those quote items are retrieved by using $product->prepareForCart. These items also include different information, such as quantity and configurable product options (on a quote item).

From a backend perspective, data for products are stored in: catalog_product_entity_*, whereas quote items are stored in sales_flat_quote_item (at least in Enterprise. someone else might want to verify this on community).


EDIT: Attaching some code that we wrote to import product inventories a while back.

$product                 = Mage::getModel("catalog/product")->load($productId);
$product->seStockData(array(
    "qty"                         => (int)$yourQuantity,
    "is_in_stock"                 => ((int)$isTheProductInStock),
    "manage_stock"                => $manageStock,
    "is_qty_decimal"              => $isQtyDecimal,
    "use_config_manage_stock"     => $useConfigManageStock,
));

Mage::getModel('catalog/product_api')->update($sku,$product->getData());

For your purposes you may just need to call $product->save();, but I'm including the whole snippet as written because it works.

Hope that helps. Thanks,
Joe

┈┾☆殇 2024-08-30 11:54:13

我的第一个答案是产品和产品报价是两个独立的实体,因此不应在统一的实体中建模。

举一个我工作的公司的例子,以及为什么我们单独对这些东西进行建模:

在我们的电子采购系统中,您可能在特定的买方和卖方之间有一份“合同”。当涉及到发票条目时,“报价”项对此进行了建模。如果没有合同,请使用正常产品价格创建报价项目,否则使用供应商和买方之间的“合同”调整价格。

My first answer would be that a product and a quote for a product are two separate entities and therefore should not be modelled in a unified entity.

An example of why would be from the company I work for, and why we model these things separately:

In our e-procurement system you might have a "contract" between a specific buyer and a seller. The "quote" item models this when it comes to invoice entries. If there isn't a contract use the normal product price to create a Quote Item else adjust the price using the "contract" between supplier and buyer.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文