Magento Certification is an important issue for any developer connected with Magento. It is not merely a sign of high-level proficiency, but also a mark of profound knowledge and devotion to this sphere. This article opens Magento certification tips and tricks series aimed to prepare its readers for passing the exam.
Amasty team already has 2 specialists who have passed Magento Certification and another 3 are on the way. We are glad to share our knowledge and help other Magento developers to find easy explanations and answers to the exam questions.
Magento Certification is divided into 10 chapters. And if you start searching information on it in the Internet, you will generally find articles about the first chapters. So we decided to take another way and to start right from Chapter 8 where Checkout process is outlined. Making it even better this topic comprises about 16% of the exam. So even if your study thirst will not suffice for the full course with this article you will have at least some basis for the exam.
How does Magento store information about the shopping cart?
We have sales_flat_quote table, where general information such as customer_id, subtotal, coupon_code, items_qty, creation and update date is stored. In case a client didn’t finish the purchase, this information is displayed in the standard report “Abandoned Carts”.
Products are stored in a separate table sales_flat_quote_item, where one can find information about the product bought, its amount, price and discount applied. Complex types of products (configurable, bundle) occupy a few rows. This is a very important moment, so let’s pay special attention to it.
How are different product types processed when added to the cart?
When we add to the cart one configurable product, let’s say an L-sized T-shirt, we in fact add 2 products: a configurable one (a T-shirt), that stores product price and its general description and a simple product (L size), which is important for accurate calculation of the items left in stock, since even if we have 5 T-shirts left in stock, only one of them might be of L size.
This way we have 2 records in the cart: parent (configurable product) and child (simple product). The reference of the simple product to the configurable one is specified in the field parent_item_id.
For the bundle product (e.g. computer) that consists of 3 components there will be 4 records: one parent (general product) and 3 for each product out of bundle.
But for the grouped product (e.g. furniture set) that consists of 3 components there will be only 3 records, since there is no parent product in the cart and information about the fact that this is a group product is stored in sales_flat_quote_item_option.
What for do Magento shop owners and developers need these data?
This would help them first and foremost to create accurate discount conditions (shopping cart rules) and secondly to define accurately shipping cost in the cases when it depends on the amount of goods. In theory the way data are stored is not important for user, but up to the latest Magento version there are cases, where this information is significant.
For example we want to provide a discount for the order in case it contains L-sized T-shirts. We go to Admin -> Promotions -> Shopping cart rules -> New rule. Then we go to tab Actions and choose L-sized T-shirt.
Test it. It doesn’t work. What’s the problem? The thing is that L size is a simple product, so it is “not displayed”.
Let’s try another way. We go to tab Conditions and create a condition “If there is at least one L-sized T-shirt…” and (wow!) it works!
But what’s the trick? This condition checks all items in the cart ignoring parent-child relations.
We don’t want to call it “bugs”, we prefer to think of them as “features”.
- Learn how custom options of products are stored. A hint: pay attention to table sales_flat_quote_item_option.
- Case study: We have a simple product with a custom option. This product is included in a configurable one that also has a custom option. How many items will there be in the quote items table? Please write your variants in the comments.
Don’t forget to check the Abandoned Cart Email extension from Amasty!