/**
  * Prepare selected options for simple subscription product
  *
  * @param  Mage_Catalog_Model_Product $product
  * @param  Varien_Object $buyRequest
  * @return array
  */
 public function processBuyRequest($product, $buyRequest)
 {
     $options = parent::processBuyRequest($product, $buyRequest);
     $option = $buyRequest->getData('adyen_subscription');
     $options['adyen_subscription'] = $option;
     return $options;
 }
示例#2
0
文件: Type.php 项目: rcclaudrey/dev
 public function isSalable($product = null)
 {
     $salable = parent::isSalable($product);
     /*if (!is_null($salable)) {
       return $salable;
        }*/
     $optionCollection = $this->getOptionsCollection($product);
     if (!count($optionCollection->getItems())) {
         return false;
     }
     $requiredOptionIds = array();
     foreach ($optionCollection->getItems() as $option) {
         if ($option->getRequired()) {
             $requiredOptionIds[$option->getId()] = 0;
         }
     }
     $selectionCollection = $this->getSelectionsCollection($optionCollection->getAllIds(), $product);
     if (!count($selectionCollection->getItems())) {
         return false;
     }
     $salableSelectionCount = 0;
     foreach ($selectionCollection as $selection) {
         if ($selection->isSalable()) {
             $requiredOptionIds[$selection->getOptionId()] = 1;
             $salableSelectionCount++;
         }
     }
     return array_sum($requiredOptionIds) == count($requiredOptionIds) && $salableSelectionCount;
 }
示例#3
0
 public function isVirtual($product = null)
 {
     $hasShipping = ITwebexperts_Payperrentals_Helper_Data::getAttributeCodeForId($this->getProduct($product)->getId(), 'payperrentals_has_shipping');
     $isReservation = ITwebexperts_Payperrentals_Helper_Data::getAttributeCodeForId($this->getProduct($product)->getId(), 'is_reservation');
     if ($isReservation != ITwebexperts_Payperrentals_Model_Product_Isreservation::STATUS_DISABLED && $isReservation != ITwebexperts_Payperrentals_Model_Product_Isreservation::STATUS_NOTSET) {
         return Mage::helper('payperrentals/config')->removeShipping() || $hasShipping == ITwebexperts_Payperrentals_Model_Product_Hasshipping::STATUS_DISABLED;
     } else {
         return parent::isVirtual($product);
     }
 }
示例#4
0
 /**
  * Allow Fixed Bundles to be added to the cart without needing to submit the add to cart form
  *
  * @param Varien_Object $buyRequest
  * @param Mage_Catalog_Model_Product $product
  * @param string $processMode
  * @return array|string
  * @author Paul Hachmang <*****@*****.**>
  */
 protected function _prepareProduct(Varien_Object $buyRequest, $product, $processMode)
 {
     $product = $this->getProduct($product);
     $options = $buyRequest->getBundleOption();
     $optionsCollection = $this->getOptionsCollection($product);
     if ($product->getTypeId() == Mage_Catalog_Model_Product_Type::TYPE_BUNDLE && count($options) <= 0) {
         foreach ($optionsCollection->getItems() as $option) {
             if ($option->getType() == self::OPTION_TYPE_FIXED && $option->getRequired() && !isset($options[$option->getId()])) {
                 $selectionData = Mage::getResourceSingleton('bundle/bundle')->getSelectionsData($product->getId());
                 foreach ($selectionData as $prod) {
                     $options[$option->getId()][] = $prod['selection_id'];
                 }
             }
         }
         //we are placing the new information in the request
         $buyRequest->setBundleOption($options);
     }
     return parent::_prepareProduct($buyRequest, $product, $processMode);
 }
示例#5
0
 public function testHasWeightTrue()
 {
     $this->assertTrue($this->_model->hasWeight(), 'This product has not weight, but it should');
 }
 /**
  * Get all the bundle data for a product
  *
  * @param Mage_Bundle_Model_Product_Type
  * @return array
  */
 protected function getBundleParentData(Mage_Bundle_Model_Product_Type $bundleParent)
 {
     /** @var Mage_Bundle_Model_Resource_Option_Collection */
     $optionCollection = $bundleParent->getOptionsCollection();
     /** @var int[] */
     $optionIds = $bundleParent->getOptionsIds();
     /** @var Mage_Bundle_Model_Resource_Selection_Collection */
     $selectionCollection = $bundleParent->getSelectionsCollection($optionIds);
     /** @var Mage_Bundle_Model_Option[] */
     $options = $optionCollection->appendSelections($selectionCollection);
     /** @var array */
     $bundleData = [];
     /** @var Mage_Bundle_Model_Option $option */
     foreach ($options as $option) {
         /** @var Mage_Catalog_Model_Product[] */
         $bundleItems = $option->getSelections();
         $bundleData[$option->getDefaultTitle()] = $this->getBundleItemData($bundleItems);
     }
     return $bundleData;
 }