Beispiel #1
0
 /**
  * @magentoDataFixture Mage/Catalog/_files/product_simple.php
  */
 public function testBeforeSave()
 {
     $product = new Mage_Catalog_Model_Product();
     $product->load(1);
     // fixture
     $product->setData('links_purchased_separately', 'value');
     // this attribute is applicable only for downloadable
     $this->_model->beforeSave($product);
     $this->assertTrue($product->canAffectOptions());
     $this->assertFalse($product->hasData('links_purchased_separately'));
 }
 /**
  * Before save process
  *
  * @param  Mage_Catalog_Model_Product $product
  * @return Mage_Catalog_Model_Product_Type_Configurable
  */
 public function beforeSave($product = null)
 {
     parent::beforeSave($product);
     $this->getProduct($product)->canAffectOptions(false);
     if ($this->getProduct($product)->getCanSaveConfigurableAttributes()) {
         $this->getProduct($product)->canAffectOptions(true);
         if ($data = $this->getProduct($product)->getConfigurableAttributesData()) {
             if (!empty($data)) {
                 foreach ($data as $attribute) {
                     if (!empty($attribute['values'])) {
                         $this->getProduct($product)->setTypeHasOptions(true);
                         $this->getProduct($product)->setTypeHasRequiredOptions(true);
                         break;
                     }
                 }
             }
         }
     }
     return $this;
 }
Beispiel #3
0
 /**
  * Before save type related data
  *
  * @param Mage_Catalog_Model_Product $product
  */
 public function beforeSave($product = null)
 {
     parent::beforeSave($product);
     $product = $this->getProduct($product);
     // If bundle product has dynamic weight, than delete weight attribute
     if (!$product->getData('weight_type') && $product->hasData('weight')) {
         $product->setData('weight', false);
     }
     if ($product->getPriceType() == Mage_Bundle_Model_Product_Price::PRICE_TYPE_DYNAMIC) {
         $product->setData('msrp_enabled', Mage_Catalog_Model_Product_Attribute_Source_Msrp_Type_Enabled::MSRP_ENABLE_NO);
         $product->unsetData('msrp');
         $product->unsetData('msrp_display_actual_price_type');
     }
     $product->canAffectOptions(false);
     if ($product->getCanSaveBundleSelections()) {
         $product->canAffectOptions(true);
         $selections = $product->getBundleSelectionsData();
         if ($selections) {
             if (!empty($selections)) {
                 $options = $product->getBundleOptionsData();
                 if ($options) {
                     foreach ($options as $option) {
                         if (empty($option['delete']) || 1 != (int) $option['delete']) {
                             $product->setTypeHasOptions(true);
                             if (1 == (int) $option['required']) {
                                 $product->setTypeHasRequiredOptions(true);
                                 break;
                             }
                         }
                     }
                 }
             }
         }
     }
 }
 public function beforeSave($product = null)
 {
     parent::beforeSave($product);
     $this->getProduct($product)->setTypeHasOptions(true);
     $this->getProduct($product)->setTypeHasRequiredOptions(true);
     return $this;
 }
Beispiel #5
0
 /**
  * Before save type related data
  *
  * @param Mage_Catalog_Model_Product $product
  */
 public function beforeSave($product = null)
 {
     parent::beforeSave($product);
     $product = $this->getProduct($product);
     // If bundle product has dynamic weight, than delete weight attribute
     if (!$product->getData('weight_type') && $product->hasData('weight')) {
         $product->setData('weight', false);
     }
     $product->canAffectOptions(false);
     if ($product->getCanSaveBundleSelections()) {
         $product->canAffectOptions(true);
         $selections = $product->getBundleSelectionsData();
         if ($selections) {
             if (!empty($selections)) {
                 $options = $product->getBundleOptionsData();
                 if ($options) {
                     foreach ($options as $option) {
                         if (empty($option['delete']) || 1 != (int) $option['delete']) {
                             $product->setTypeHasOptions(true);
                             if (1 == (int) $option['required']) {
                                 $product->setTypeHasRequiredOptions(true);
                                 break;
                             }
                         }
                     }
                 }
             }
         }
     }
 }
 public function beforeSave($product = null)
 {
     parent::beforeSave($product);
     if ($product->getAwSarpEnabled() && $this->getProduct($product)->getAwSarpSubscriptionPrice() == '') {
         $this->getProduct($product)->setAwSarpSubscriptionPrice($product->getData('price'));
     }
 }
Beispiel #7
0
 /**
  * Before save type related data
  *
  * @param Mage_Catalog_Model_Product $product
  */
 public function beforeSave($product = null)
 {
     parent::beforeSave($product);
     $this->getProduct($product)->canAffectOptions(false);
     if ($this->getProduct($product)->getCanSaveBundleSelections()) {
         $this->getProduct($product)->canAffectOptions(true);
         if ($selections = $this->getProduct($product)->getBundleSelectionsData()) {
             if (!empty($selections)) {
                 if ($options = $this->getProduct($product)->getBundleOptionsData()) {
                     foreach ($options as $option) {
                         if (empty($option['delete']) || 1 != (int) $option['delete']) {
                             $this->getProduct($product)->setTypeHasOptions(true);
                             if (1 == (int) $option['required']) {
                                 $this->getProduct($product)->setTypeHasRequiredOptions(true);
                                 break;
                             }
                         }
                     }
                 }
             }
         }
     }
 }