簡體   English   中英

Magento:如何將自定義產品屬性傳遞給訂單

[英]Magento: How to pass custom product attribute to order

使用Magento CE 1.8.x,我正在嘗試獲取自定義產品屬性以傳遞給在幕后使用的訂單項。 我在catalog > attributes > manage attributes創建了自定義產品屬性qb_product_id

然后我創建了以下模塊:

config.xml中

<?xml version="1.0"?>
<config>
<modules>
    <Nellys_QBProductID>
        <version>0.1.0</version>   
    </Nellys_QBProductID>
</modules>

<global>
<fieldsets>
    <sales_convert_quote_item>
        <qb_product_id>
            <to_order_item>*</to_order_item>
        </qb_product_id>
    </sales_convert_quote_item>

    <sales_convert_order_item>
        <qb_product_id>
            <to_quote_item>*</to_quote_item>
        </qb_product_id>
    </sales_convert_order_item>
</fieldsets>

<sales>
    <quote>
        <item>
            <product_attributes>
                <qb_product_id />
            </product_attributes>
        </item>
    </quote>
</sales>

<events>
    <sales_quote_item_set_product>
        <observers>
            <Nellys_QBProductID>
                <class>Nellys_QBProductID_Model_Observer</class>
                <method>setQbProductId</method>
            </Nellys_QBProductID>
        </observers>
    </sales_quote_item_set_product>
</events>
</global>

</config>

Observer.php

<?php
class Nellys_QBProductID_Model_Observer extends Varien_Event_Observer
{
public function setQbProductId(Varien_Event_Observer $observer) {
    $item = $observer->getQuoteItem();
    $product = $observer->getProduct();
    $item->setQbProductId($product->getQbProductId());
    return $this;
}
}

?>

當我轉儲訂單商品信息時,它似乎沒有輸出qb_invoice_id 知道我哪里錯了嗎? 我已經清除了我的var / cache文件夾並重新編制了所有索引,但仍未顯示訂單項。

可能需要在sales_order_table上安裝該屬性?

在Magento中為訂單添加自定義屬性與我們對客戶和類別相同。 不同的是我們將使用不同的安裝類,現在我們不需要屬性集,組和屬性輸入類型。 我們將創建一個快速模塊,它將完全符合我們的要求,僅此而已。 所以你需要為此創建模塊。 請訪問以下網址。

http://ka.lpe.sh/2013/05/10/magento-add-attribute-to-order/

https://www.atwix.com/magento/custom-product-attribute-quote-order-item/

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM