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)
精彩评论