Why does the Magento cart.create function make the basket inactive?

I worked with the Magento Recycle Bin API (Magento v.1.5) and found that when creating the Recycle Bin (and added products), the value "is_active" in the table "sales_flat_quote" is "0". Conversely, if you use the Add to Cart button in the store interface, the value of is_active is set to 1.

I did a bit of work and found that the API sets "is_active" in app / code / core / Mage / Checkout / Model / Cart / Api.php.

Here is the corresponding code block:

public function create($store = null) { $storeId = $this->_getStoreId($store); try { /*@var $quote Mage_Sales_Model_Quote*/ $quote = Mage::getModel('sales/quote'); $quote->setStoreId($storeId) ->setIsActive(false) ->setIsMultiShipping(false) ->save(); } catch (Mage_Core_Exception $e) { $this->_fault('create_quote_fault', $e->getMessage()); } return (int) $quote->getId(); } 

Therefore, I am not sure if this is the intention to make it false. Is there a reason for the difference in behavior between the store interface and the API? Or is there something extra that needs to be done through the API to make the cart active?

+4
source share
1 answer

My best guess, and this assumption, since I cannot read the original minds of the developers, would they try to prevent quotes generated by the API from appearing in reports of abandoned carts.

The is_active flag is used to indicate the active price for the client, and the client should have only one active quote. The flag is also used to know when a quote can be automatically removed from the system, and the theory is that if the quote is inactive, it was converted to order and is no longer needed. If the Mage_Checkout Cart API sets the flag to false, then the quote is automatically cleared, perhaps before you convert it to an order. By setting the flag to false, it also does not allow you to use the API to create a live quote that the client can use in the external interface.

So, I would say if you use the API to create a quote for the client, you need to add the publish () method. If you use the API to modify an existing client quote, you will not run into a problem, since it appears only when creating a new quote.

In any case, I would personally think that the current behavior is an error due to cleanup procedures using this flag to indicate replaceable quotation marks.

+2
source

All Articles