示例#1
0
 /**
  * @magentoDataFixture Mage/Downloadable/_files/product_with_files.php
  */
 public function testDeleteTypeSpecificData()
 {
     $product = Mage::getModel('Mage_Catalog_Model_Product');
     $product->load(1);
     Mage::app()->setCurrentStore(Mage_Core_Model_App::ADMIN_STORE_ID);
     $product->setOrigData();
     $downloadableData = array();
     $links = $this->_model->getLinks($product);
     $this->assertNotEmpty($links);
     $samples = $this->_model->getSamples($product);
     $this->assertNotEmpty($samples->getData());
     foreach ($links as $link) {
         $downloadableData['link'][] = $link->getData();
     }
     foreach ($samples as $sample) {
         $downloadableData['sample'][] = $sample->getData();
     }
     $product->setDownloadableData($downloadableData);
     $this->_model->deleteTypeSpecificData($product);
     $product = Mage::getModel('Mage_Catalog_Model_Product');
     $product->load(1);
     $links = $this->_model->getLinks($product);
     $this->assertEmpty($links);
     $samples = $this->_model->getSamples($product);
     $this->assertEmpty($samples->getData());
 }
示例#2
0
 public function testHasWeightFalse()
 {
     $this->assertFalse($this->_model->hasWeight(), 'This product has weight, but it should not');
 }
 public function beforeSave($product = null)
 {
     parent::beforeSave($product);
     if ($product->getAwSarpEnabled() && $this->getProduct($product)->getAwSarpSubscriptionPrice() == '') {
         $this->getProduct($product)->setAwSarpSubscriptionPrice($product->getData('price'));
     }
 }
 /**
  * Prepare additional options/information for order item which will be
  * created from this product
  *
  * @param Mage_Catalog_Model_Product $product
  * @return array
  */
 public function getOrderOptions($product = null)
 {
     $options = parent::getOrderOptions($product);
     if ($linkIds = $this->getProduct($product)->getCustomOption('downloadable_link_ids')) {
         $linkOptions = array();
         $links = $this->getLinks($product);
         foreach (explode(',', $linkIds->getValue()) as $linkId) {
             if (isset($links[$linkId])) {
                 $linkOptions[] = $linkId;
             }
         }
         $options = array_merge($options, array('links' => $linkOptions));
         if (count($linkOptions) == 0) {
             // Gorilla Custom log: ticket#2014062010000282
             Mage::log(__METHOD__ . ':' . __LINE__ . ": No links in order options for " . $product->getId() . ". Product links: " . implode(', ', array_keys($links)), null, 'downloadable_missing_links.log');
         }
     } else {
         // Gorilla Custom log: ticket#2014062010000282
         Mage::log(__METHOD__ . ':' . __LINE__ . ": No link id for downloadable_link_ids found for " . $product->getId(), null, 'downloadable_missing_links.log');
     }
     $options = array_merge($options, array('is_downloadable' => true, 'real_product_type' => self::TYPE_DOWNLOADABLE));
     return $options;
 }