Example #1
0
 /**
  * Method is needed for specific actions to change given quote options values
  * according current product type logic
  * Example: the cataloginventory validation of decimal qty can change qty to int,
  * so need to change quote item qty option value too.
  *
  * @param   array           $options
  * @param   Varien_Object   $option
  * @param   mixed           $value
  * @param   Mage_Catalog_Model_Product $product
  * @return  Mage_Bundle_Model_Product_Type
  */
 public function updateQtyOption($options, Varien_Object $option, $value, $product = null)
 {
     $optionProduct = $option->getProduct($product);
     $optionUpdateFlag = $option->getHasQtyOptionUpdate();
     $optionCollection = $this->getOptionsCollection($product);
     $selections = $this->getSelectionsCollection($optionCollection->getAllIds(), $product);
     foreach ($selections as $selection) {
         if ($selection->getProductId() == $optionProduct->getId()) {
             foreach ($options as &$option) {
                 if ($option->getCode() == 'selection_qty_' . $selection->getSelectionId()) {
                     if ($optionUpdateFlag) {
                         $option->setValue(intval($option->getValue()));
                     } else {
                         $option->setValue($value);
                     }
                 }
             }
         }
     }
     return $this;
 }