The quote model has a method getSharedStoreIds()
which by default returns all store ids of a website. The return of this method is applied to the quote select for loading.
Therefore you can simply set the current store into the array of shared store ids before loading like this:
Mage::getModel('sales/quote')
->setStoreId(Mage::app()->getStore()->getId()) //this is just a simple setter and does not restrict anything
->setData('shared_store_ids', [Mage::app()->getStore()->getStoreId()]) //here happens the magic of store restriction
->load([Put whatever quote id here]);
Now the problem is to identify where to use that approch and what you need to change?
The simplest would be to create an observer for the event sales_quote_load_before
and use a method like this there:
public function addSharedStoreIdsFilter($observer)
{
$quote = $observer->getQuote();
$quote->setData('shared_store_ids', [Mage::app()->getStore()->getStoreId()]);
}
Unfortunatelly that will not work in all situations since in the quote model there are some 'loadXXX' methods which are bypassing the before loading method (for what ever reason), for example if a customer logs in the method
loadByCustomer
.
Therefore the "nice" solution from above can work only if you overwrite the quote model and add $this->_beforeLoad();
in loadByCustomer($customer)
and loadActive($quoteId)
before
accessing the resource.
Just for information of others who are reading this question: In Magento 2 there is a nicer way to achieve this: Disable cart sharing between different Stores of website in Magento 2?