开发者

How can I persist some data with a Magento Quote Item for reference on checkout?

开发者 https://www.devze.com 2023-04-09 04:08 出处:网络
I need to persist some data associated to a product and then process it on checkout. This is internal data that isn\'t visible to the user, however it is calculated when a user is adding an item to th

I need to persist some data associated to a product and then process it on checkout. This is internal data that isn't visible to the user, however it is calculated when a user is adding an item to the cart.

I've tried extending the Cart Model's addProduct() call and using:

$product->setData('some_var', $my_d开发者_Python百科ata);

However, on the checkout, when I do:

$items = $this->getOnepage()->getQuote()->getAllItems();

foreach($items as $item)
{
   echo $item->getData('some_var');
}

That item doesn't persist.

I assume it's not actually storing the item but saving all of the product id's and regenerating the collection.

Any advice on this would be greatly appreciated.


It's easier to add new attribute for product and then add quote item definition to the config.xml

<global>
    <sales>
        <quote>
            <item>
                <product_attributes>
                    <your_attirubute_code />
                </product_attributes>
            </item>
        </quote>
    </sales>
</global>

Also this attribute must used in product listing. ("Used in Product Listing" = Yes)

0

精彩评论

暂无评论...
验证码 换一张
取 消