當前位置: 首頁>>代碼示例>>PHP>>正文


PHP Mage_Catalog_Model_Product::setOrigData方法代碼示例

本文整理匯總了PHP中Mage_Catalog_Model_Product::setOrigData方法的典型用法代碼示例。如果您正苦於以下問題:PHP Mage_Catalog_Model_Product::setOrigData方法的具體用法?PHP Mage_Catalog_Model_Product::setOrigData怎麽用?PHP Mage_Catalog_Model_Product::setOrigData使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在Mage_Catalog_Model_Product的用法示例。


在下文中一共展示了Mage_Catalog_Model_Product::setOrigData方法的8個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的PHP代碼示例。

示例1: testReset

 public function testReset()
 {
     $model = $this->_model;
     $testCase = $this;
     $assertEmpty = function () use($model, $testCase) {
         $testCase->assertEquals(array(), $model->getData());
         $testCase->assertEquals(null, $model->getOrigData());
         $testCase->assertEquals(array(), $model->getCustomOptions());
         // impossible to test $_optionInstance
         $testCase->assertEquals(array(), $model->getOptions());
         $testCase->assertFalse($model->canAffectOptions());
         // impossible to test $_errors
     };
     $assertEmpty();
     $this->_model->setData('key', 'value');
     $this->_model->reset();
     $assertEmpty();
     $this->_model->setOrigData('key', 'value');
     $this->_model->reset();
     $assertEmpty();
     $this->_model->addCustomOption('key', 'value');
     $this->_model->reset();
     $assertEmpty();
     $this->_model->addOption(new Mage_Catalog_Model_Product_Option());
     $this->_model->reset();
     $assertEmpty();
     $this->_model->canAffectOptions(true);
     $this->_model->reset();
     $assertEmpty();
 }
開發者ID:relue,項目名稱:magento2,代碼行數:30,代碼來源:ProductTest.php

示例2: testAfterSave

 /**
  * @magentoConfigFixture current_store catalog/price/scope 1
  * @magentoConfigFixture current_store currency/options/base GBP
  */
 public function testAfterSave()
 {
     $product = new Mage_Catalog_Model_Product();
     $product->load(1);
     $product->setOrigData();
     $product->setPrice(9.99);
     $product->setStoreId(0);
     $this->_model->setScope($this->_model->getAttribute());
     $this->_model->afterSave($product);
     $this->assertEquals('9.99', $product->getResource()->getAttributeRawValue($product->getId(), $this->_model->getAttribute()->getId(), Mage::app()->getStore()->getId()));
 }
開發者ID:NatashaOlut,項目名稱:Mage_Test,代碼行數:15,代碼來源:Price.php

示例3: testCalaogProductSaveAfter

 /**
  * @test
  */
 public function testCalaogProductSaveAfter()
 {
     $this->_fpc->save('product1', 'product1_cache_id', array(sha1('product_1')));
     $this->_fpc->save('category1', 'category1_cache_id', array(sha1('category_1')));
     $this->_fpc->save('category2', 'category2_cache_id', array(sha1('category_2')));
     $product = new Mage_Catalog_Model_Product();
     $product->setOrigData(array());
     $product->setCategoryIds(array(1));
     $product->setId(1);
     Mage::dispatchEvent('catalog_product_save_after', array('product' => $product));
     $this->assertFalse($this->_fpc->load('product1_cache_id'));
     $this->assertFalse($this->_fpc->load('category1_cache_id'));
     $this->assertEquals('category2', $this->_fpc->load('category2_cache_id'));
 }
開發者ID:AndreKlang,項目名稱:Lesti_Fpc,代碼行數:17,代碼來源:Save.php

示例4: testReset

 public function testReset()
 {
     $model = $this->_model;
     $this->_assertEmpty($model);
     $this->_model->setData('key', 'value');
     $this->_model->reset();
     $this->_assertEmpty($model);
     $this->_model->setOrigData('key', 'value');
     $this->_model->reset();
     $this->_assertEmpty($model);
     $this->_model->addCustomOption('key', 'value');
     $this->_model->reset();
     $this->_assertEmpty($model);
     $this->_model->addOption(new Mage_Catalog_Model_Product_Option());
     $this->_model->reset();
     $this->_assertEmpty($model);
     $this->_model->canAffectOptions(true);
     $this->_model->reset();
     $this->_assertEmpty($model);
 }
開發者ID:nemphys,項目名稱:magento2,代碼行數:20,代碼來源:ProductTest.php

示例5: afterLoad

 /**
  * Assign group prices to product data
  *
  * @param Mage_Catalog_Model_Product $object
  * @return Mage_Catalog_Model_Product_Attribute_Backend_Groupprice_Abstract
  */
 public function afterLoad($object)
 {
     $storeId = $object->getStoreId();
     $websiteId = null;
     if ($this->getAttribute()->isScopeGlobal()) {
         $websiteId = 0;
     } else {
         if ($storeId) {
             $websiteId = Mage::app()->getStore($storeId)->getWebsiteId();
         }
     }
     $data = $this->_getResource()->loadGroupData($object->getId(), $websiteId);
     foreach ($data as $k => $v) {
         //$data[$k]['website_price'] = $v['price'];
         if ($v['all_groups']) {
             $data[$k]['cust_group'] = Mage_Customer_Model_Group::CUST_GROUP_ALL;
         }
     }
     $object->setData($this->getAttribute()->getName(), $data);
     $object->setOrigData($this->getAttribute()->getName(), $data);
     $valueChangedKey = $this->getAttribute()->getName() . '_changed';
     $object->setOrigData($valueChangedKey, 0);
     $object->setData($valueChangedKey, 0);
     return $this;
 }
開發者ID:cnglobal-sl,項目名稱:caterez,代碼行數:31,代碼來源:Abstract.php

示例6: testAfterSaveEmpty

 /**
  * @depends testAfterSave
  */
 public function testAfterSaveEmpty()
 {
     Mage::app()->setCurrentStore(Mage::app()->getStore(Mage_Core_Model_App::ADMIN_STORE_ID));
     $product = new Mage_Catalog_Model_Product();
     $product->load(1);
     $product->setOrigData();
     $product->setTierPrice(array());
     $this->_model->afterSave($product);
     $product = new Mage_Catalog_Model_Product();
     $product->setId(1);
     $this->_model->afterLoad($product);
     $this->assertEmpty($product->getTierPrice());
 }
開發者ID:relue,項目名稱:magento2,代碼行數:16,代碼來源:TierpriceTest.php

示例7: afterLoad

 /**
  * Assign tier prices to product data
  *
  * @param Mage_Catalog_Model_Product $object
  * @return Mage_Catalog_Model_Product_Attribute_Backend_Tierprice
  */
 public function afterLoad($object)
 {
     $storeId = $object->getStoreId();
     $websiteId = null;
     if ($this->getAttribute()->isScopeGlobal()) {
         $websiteId = 0;
     } else {
         if ($storeId) {
             $websiteId = Mage::app()->getStore($storeId)->getWebsiteId();
         }
     }
     $data = $this->_getResource()->loadPriceData($object->getId(), $websiteId);
     foreach ($data as $k => $v) {
         $data[$k]['website_price'] = $v['price'];
         if ($v['all_groups']) {
             $data[$k]['cust_group'] = Mage_Customer_Model_Group::CUST_GROUP_ALL;
         }
     }
     if (!$object->getData('_edit_mode') && $websiteId) {
         $rates = $this->_getWebsiteRates();
         $full = $data;
         $data = array();
         foreach ($full as $v) {
             $key = join('-', array($v['cust_group'], $v['price_qty']));
             if ($v['website_id'] == $websiteId) {
                 $data[$key] = $v;
                 $data[$key]['website_price'] = $v['price'];
             } else {
                 if ($v['website_id'] == 0 && !isset($data[$key])) {
                     $data[$key] = $v;
                     $data[$key]['website_id'] = $websiteId;
                     if ($object->getPriceModel()->isTierPriceFixed()) {
                         $data[$key]['price'] = $v['price'] * $rates[$websiteId]['rate'];
                         $data[$key]['website_price'] = $v['price'] * $rates[$websiteId]['rate'];
                     }
                 }
             }
         }
     }
     $object->setData($this->getAttribute()->getName(), $data);
     $object->setOrigData($this->getAttribute()->getName(), $data);
     $valueChangedKey = $this->getAttribute()->getName() . '_changed';
     $object->setOrigData($valueChangedKey, 0);
     $object->setData($valueChangedKey, 0);
     return $this;
 }
開發者ID:hunnybohara,項目名稱:magento-chinese-localization,代碼行數:52,代碼來源:Tierprice.php

示例8: setOrigData

 /**
  * Set original loaded data if needed
  *
  * @param string $key
  * @param mixed $data
  * @return Varien_Object
  */
 public function setOrigData($key = null, $data = null)
 {
     if (Mage::app()->getStore()->isAdmin()) {
         return parent::setOrigData($key, $data);
     }
     return $this;
 }
開發者ID:WesleyDevLab,項目名稱:magento-app-v2,代碼行數:14,代碼來源:Product.php


注:本文中的Mage_Catalog_Model_Product::setOrigData方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。