Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Magento: What is the conceptual difference between a Quote Item and a Quote Address Item?

Tags:

magento

Inspired by another question I saw recently on SO, I wanted to see if anyone could explain the difference between a Quote Item (Mage_Sales_Model_Quote_Item) and a Quote Address Item (Mage_Sales_Model_Quote_Address_Item)?

I think I understand the concept of a Quote Item (Mage_Sales_Model_Quote_Item - mapped to sales_flat_quote_item db table) - basically a line item in the customer's cart which includes the name/sku of the product, quantity, and any special options. What I don't understand is what the Quote Address Item Mage_Sales_Model_Quote_Address_Item - mapped to sales_flat_quote_address_item db table) is for. I see that it has an address associated to it, but what the heck is that for? I can imagine that it might have something to do with multi-address shipping (which I have never used) but that is a wild guess.

As a secondary question (actually the whole reason for this question :/), are there any cases where a custom module dealing with Quote Items could safely ignore the Quote Address Item?

like image 616
shaune Avatar asked Feb 09 '11 17:02

shaune


2 Answers

I've dealt with this before.

Basically the quote item is as you described it. It represents a line item in the cart with all of its details.

As for the quote address item, it is just an object that contains a reference to the quote item object, a reference to a address object and the subset quantity out of the quote item that is to be shipped to this particular address (but then they duplicate everything from the quote item to it uselessly).

In case of multishipping checkout, it is the quote address items that are used to create several Magento Order objects (each order as if it were separate with a subset of the quote items).

Of course, this is a clunky design. It would have been better if they just kept the quote item data and added an address id field and eliminated the "quote address item" concept entirely. Looks like a case of excessive normalization that backfired on them.

Code that wants to mess with the cart can safely ignore quote address items in case of dealing only with onepage checkout (and multishipping is disabled).

If you want to also have the changes appear correctly in multishipping checkout, you have to also mess with quote address items (and the code in these areas is quite ugly).

like image 175
Raif Atef Avatar answered Oct 29 '22 02:10

Raif Atef


Its related to "ship to multiple addresses" as each item needs to be mapped to separate address

like image 20
Anton S Avatar answered Oct 29 '22 02:10

Anton S