本文整理汇总了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();
}
示例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()));
}
示例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'));
}
示例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);
}
示例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;
}
示例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());
}
示例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;
}
示例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;
}