php - Difference between two commands of fetching Shopping Cart Items in Magento -


If you need to get / receive item descriptions of shopping cart, you can do it in any of two Methods that will provide you all the items in a array: -

  1. $ cartItems1 = $ cart-> GetQuote () - & gt; All items found ();
  2. $ cartItems2 = $ cart-> GetItems () - & gt; GetData ();

    $ Cart = new Mage_Checkout_Model_Cart (); $ Cart- & gt; Init ();

    Can anyone describe in detail what the two options provide?

    In any more option, available in Magento, can anyone expose it?

If you look at the code of the cart and the coat class, everything will be clear.

Code for $ Cart-> getItems () here:

  public function getItems () {return $ this-> getQuote () - & gt; GetAllVisibleItems (); }  

Simple and simple - this is just a method of quote item, so the question is now: getAllVisibleItems () and getAllItems ( ) ? What's the difference between

? Code for both methods:

  public function getAllItems () {$ items = array (); Forex Currency ($ this-> GetItemsCollection () as $ item) {If (! $ Item-> Deleted ()) {$ items [] = $ item; }} Return $ item; } Public function getAllVisibleItems () {$ items = array (); Forex Currency ($ this-> GetItemsCollection () as $ item) {if (! $ Item- & gt; deleted) & amp; Amp;! Item- & gt; GetParentItemId ()) {$ items [] = $ item; }} Return $ item; }  

The only difference: getAllVisibleItems () has additional checks for each item:

 ! $ Item- & gt; GetParentItemId ()  

It tests the parents of the product (in other words, it tests that it is a simple product). getAllItems ()

What are the other ways to recover items?

One must obtain a product archive directly from the citation object:

  $ productCollection = $ cart- & gt; GetQuote () - gt; GetItemsCollection ();  

Comments

Popular posts from this blog

windows - Heroku throws SQLITE3 Read only exception -

lex - Building a lexical Analyzer in Java -

python - rename keys in a dictionary -