/**
  * Processes the product and its options before adding it to a quote or a wishlist
  *
  * @param Varien_Object              $buyRequest  request object
  * @param Mage_Catalog_Model_Product $product     product ibject
  * @param string                     $processMode process mode: strict for cart, lite for wishlist
  *
  * @return array|string
  */
 protected function _prepareProduct(Varien_Object $buyRequest, $product, $processMode)
 {
     if ($this->_isStrictProcessMode($processMode)) {
         return Mage::helper('solvingmagento_affiliateproduct')->__('Affiliate product %s cannot be added to cart. ' . ' On the product detail page click the "Go to parent site" button to access the product.', $product->getName());
     }
     return parent::_prepareProduct($buyRequest, $product, $processMode);
 }
Esempio n. 2
0
 public function prepareForCart(Varien_Object $buyRequest, $product = null)
 {
     $product = $this->getProduct($product);
     parent::prepareForCart($buyRequest, $product);
     if ($buyRequest->getcpid()) {
         $product->addCustomOption('cpid', $buyRequest->getcpid());
     }
     return array($product);
 }
Esempio n. 3
0
 protected function _prepareProduct(Varien_Object $buyRequest, $product, $processMode)
 {
     if ($this->_isStrictProcessMode($processMode)) {
         /** @var Meanbee_VIPMembership_Helper_Data $_helper */
         $_helper = Mage::helper('meanbee_vipmembership');
         $customer = Mage::getSingleton('customer/session')->getCustomer();
         // Check if the customer isn't logged in.
         if (!$customer->getId()) {
             return $_helper->__('You must be logged in to buy become a VIP member');
         }
         // Check if the customer is already a VIP customer, and throw an error if so.
         if ($_helper->isCustomerVIP($customer->getId())) {
             return $_helper->__('You are already an active VIP customer!');
         }
     }
     return parent::_prepareProduct($buyRequest, $product, $processMode);
 }
Esempio n. 4
0
 /**
  * Check is product available for sale
  *
  * @param Mage_Catalog_Model_Product $product
  * @return bool
  */
 public function isSalable($product = null)
 {
     return $this->hasLinks($product) && parent::isSalable($product);
 }
Esempio n. 5
0
 /**
  * Retrieve additional searchable data from type instance
  * Using based on product id and store_id data
  *
  * @param Mage_Catalog_Model_Product $product
  * @return array
  */
 public function getSearchableData($product = null)
 {
     $searchData = parent::getSearchableData($product);
     $product = $this->getProduct($product);
     $linkSearchData = Mage::getSingleton('package/link')->getSearchableData($product->getId(), $product->getStoreId());
     if ($linkSearchData) {
         $searchData = array_merge($searchData, $linkSearchData);
     }
     $sampleSearchData = Mage::getSingleton('package/sample')->getSearchableData($product->getId(), $product->getStoreId());
     if ($sampleSearchData) {
         $searchData = array_merge($searchData, $sampleSearchData);
     }
     return $searchData;
 }
Esempio n. 6
0
 /**
  * Setting flag if dowenloadable product can be or not in complex product
  * based on link can be purchased separately or not
  *
  * @param Mage_Catalog_Model_Product $product
  */
 public function beforeSave($product = null)
 {
     parent::beforeSave($product);
     if ($this->getLinkSelectionRequired($product)) {
         $this->getProduct($product)->setTypeHasOptions(true);
         $this->getProduct($product)->setTypeHasRequiredOptions(true);
     } else {
         $this->getProduct($product)->setTypeHasOptions(false);
         $this->getProduct($product)->setTypeHasRequiredOptions(false);
     }
 }
Esempio n. 7
0
 public function testIsVirtual()
 {
     $model = new Mage_Catalog_Model_Product_Type_Virtual();
     $product = new Mage_Catalog_Model_Product();
     $this->assertTrue($model->isVirtual($product));
 }
Esempio n. 8
0
 public function testHasWeightFalse()
 {
     $this->assertFalse($this->_model->hasWeight(), 'This product has weight, but it should not');
 }
 public function prepareForCartAdvanced(Varien_Object $buyRequest, $product = null, $processMode = null)
 {
     Mage::getModel('sarp/product_type_default')->checkPeriod($product, $buyRequest);
     $Period = Mage::getModel('sarp/period');
     /* We should add custom options that doesnt exist */
     if ($buyRequest->getAwSarpSubscriptionType()) {
         if ($Period->load($buyRequest->getAwSarpSubscriptionType())->getId()) {
             $product->addCustomOption('aw_sarp_subscription_type', $Period->getId());
         }
     }
     if ($this->requiresSubscriptionOptions($product) && !$Period->getId()) {
         throw new Mage_Core_Exception(Mage::helper('sarp')->__("Selected product requires subscription options"));
     }
     if ($buyRequest->getAwSarpSubscriptionStart() && $Period->getId()) {
         $date = new Zend_Date($buyRequest->getAwSarpSubscriptionStart(), Mage::app()->getLocale()->getDateFormat(Mage_Core_Model_Locale::FORMAT_TYPE_SHORT));
         // Check date
         // Never check if start date
         //$performDateCompare = !!Mage::getSingleton('customer/session')->getCustomer()->getId();
         $performDateCompare = !AW_Sarp_Model_Cron::$isCronSession;
         $today = new Zend_Date();
         if (!$this->isVirtual($product)) {
             $today->addDayOfYear($Period->getPaymentOffset());
         }
         if ($performDateCompare && ($date->compare($today, Zend_Date::DATE_SHORT) < 0 || !$Period->isAllowedDate($date, $product))) {
             throw new Mage_Core_Exception(Mage::helper('sarp')->__("Selected date is not valid for specified period"));
         }
     } else {
         $date = Mage::app()->getLocale()->date();
     }
     $product->addCustomOption('aw_sarp_subscription_start', $date->toString('Y-MM-dd'));
     $result = Mage_Catalog_Model_Product_Type_Virtual::prepareForCartAdvanced($buyRequest, $product);
     if (is_string($result)) {
         return $result;
     }
     $preparedLinks = array();
     if ($this->getProduct($product)->getLinksPurchasedSeparately()) {
         if ($links = $buyRequest->getLinks()) {
             foreach ($this->getLinks($product) as $link) {
                 if (in_array($link->getId(), $links)) {
                     $preparedLinks[] = $link->getId();
                 }
             }
         }
     } else {
         foreach ($this->getLinks($product) as $link) {
             $preparedLinks[] = $link->getId();
         }
     }
     if ($preparedLinks) {
         $this->getProduct($product)->addCustomOption('downloadable_link_ids', implode(',', $preparedLinks));
         return $result;
     }
     return $result;
 }
Esempio n. 10
0
 /**
  * Setting flag if dowenloadable product can be or not in complex product
  * based on link can be purchased separately or not
  *
  */
 public function beforeSave()
 {
     parent::beforeSave();
     $this->getProduct()->canAffectOptions(true);
     if ($this->getLinkSelectionRequired()) {
         $this->getProduct()->setTypeHasOptions(true);
         $this->getProduct()->setTypeHasRequiredOptions(true);
     } else {
         $this->getProduct()->setTypeHasOptions(false);
         $this->getProduct()->setTypeHasRequiredOptions(false);
     }
 }