Skip to content

Instantly share code, notes, and snippets.

@kstasik
Created January 19, 2017 07:26
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save kstasik/5f04033cf5929c88138b848ee25f452e to your computer and use it in GitHub Desktop.
Save kstasik/5f04033cf5929c88138b848ee25f452e to your computer and use it in GitHub Desktop.
<?php
class Module_Sales_Model_Resource_Quote_Item_Collection extends
Mage_Sales_Model_Resource_Quote_Item_Collection{
/**
* Add products to items and item options
*
* @return Mage_Sales_Model_Resource_Quote_Item_Collection
*/
protected function _assignProducts()
{
parent::_assignProducts();
foreach($this->getItemsByColumnValue('product_type', 'configurable') as $item){
if(!$this->getItemByColumnValue('parent_item_id', $item->getId())){
if($option = $item->getOptionByCode('info_buyRequest')){
$buyRequest = new Varien_Object(unserialize($option->getValue()));
$buyRequest->unsetData('reset_count');
try{
$this->_quote->updateItem((int)$item->getId(), $buyRequest);
}
catch(Exception $e){
// product out of stock
}
}
}
}
return $this;
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment