本文整理汇总了PHP中Mage_Eav_Model_Entity_Attribute_Backend_Abstract类的典型用法代码示例。如果您正苦于以下问题:PHP Mage_Eav_Model_Entity_Attribute_Backend_Abstract类的具体用法?PHP Mage_Eav_Model_Entity_Attribute_Backend_Abstract怎么用?PHP Mage_Eav_Model_Entity_Attribute_Backend_Abstract使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了Mage_Eav_Model_Entity_Attribute_Backend_Abstract类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: _isCallableAttributeInstance
/**
* Check whether attribute instance (attribute, backend, frontend or source) has method and applicable
*
* @param Mage_Eav_Model_Entity_Attribute_Abstract|Mage_Eav_Model_Entity_Attribute_Backend_Abstract|Mage_Eav_Model_Entity_Attribute_Frontend_Abstract|Mage_Eav_Model_Entity_Attribute_Source_Abstract $instance
* @param string $method
* @param array $args array of arguments
* @return boolean
*/
protected function _isCallableAttributeInstance($instance, $method, $args)
{
if ($instance instanceof Mage_Eav_Model_Entity_Attribute_Backend_Abstract && ($method == 'beforeSave' || ($method = 'afterSave'))) {
$attributeCode = $instance->getAttribute()->getAttributeCode();
if (isset($args[0]) && $args[0] instanceof Varien_Object && $args[0]->getData($attributeCode) === false) {
return false;
}
}
return parent::_isCallableAttributeInstance($instance, $method, $args);
}
示例2: beforeSave
/**
* Performed before data is saved
*
* @param Varieb_Object $object
* @return Mage_Eav_Model_Entity_Attribute_Backend_Abstract
*/
public function beforeSave($object)
{
if ($object->getShipment()) {
$object->setParentId($object->getShipment()->getId());
}
return parent::beforeSave($object);
}
示例3: beforeSave
/**
* Before save method
*
* @param Varien_Object $object
* @return Mage_Eav_Model_Entity_Attribute_Backend_Abstract
*/
public function beforeSave($object)
{
$attributeCode = $this->getAttribute()->getAttributeCode();
$attributeValue = $object->getData($attributeCode);
$delimiter = Glace_Menumobile_Block_Category_Attribute_Helper_Dropdown_Blocks::DELIMITER;
$maxBlocks = Glace_Menumobile_Block_Category_Attribute_Helper_Dropdown_Blocks::MAX_BLOCKS;
if ($attributeValue) {
//To make parsing simpler, replace value with empty string if all blocks are empty
$exploded = explode($delimiter, $attributeValue);
$allBlocksAreEmpty = TRUE;
for ($i = 0; $i < $maxBlocks; $i++) {
if (isset($exploded[$i])) {
if (trim($exploded[$i])) {
//Block is not empty after trimming
$allBlocksAreEmpty = FALSE;
break;
}
}
}
if ($allBlocksAreEmpty) {
$object->setData($attributeCode, '');
//Set empty value
}
}
return parent::beforeSave($object);
}
开发者ID:vinayshuklasourcefuse,项目名称:sareez,代码行数:32,代码来源:Glace_Menumobile_Model_Category_Attribute_Backend_Dropdown_Blocks.php
示例4: beforeSave
/**
* Method is invoked before save
*
* @param Varien_Object $object
* @return Mage_Eav_Model_Entity_Attribute_Backend_Abstract
*/
public function beforeSave($object)
{
if ($object->getCreditmemo()) {
$object->setParentId($object->getCreditmemo()->getId());
}
return parent::beforeSave($object);
}
示例5: testGetAffectedFields
public function testGetAffectedFields()
{
$valueId = 10;
$attributeId = 42;
$attribute = $this->getMock('Mage_Eav_Model_Entity_Attribute_Abstract', array('getBackendTable', 'isStatic', 'getAttributeId'), array(), '', false);
$attribute->expects($this->any())->method('getAttributeId')->will($this->returnValue($attributeId));
$attribute->expects($this->any())->method('isStatic')->will($this->returnValue(false));
$attribute->expects($this->any())->method('getBackendTable')->will($this->returnValue('table'));
$this->_model->setAttribute($attribute);
$object = new Varien_Object();
$this->_model->setValueId($valueId);
$this->assertEquals(array('table' => array(array('value_id' => $valueId, 'attribute_id' => $attributeId))), $this->_model->getAffectedFields($object));
}
示例6: afterSave
/**
* Save uploaded file and set its name to entity
*
* @param Goodahead_Etm_Model_Entity $object
* @return void
*/
public function afterSave($object)
{
parent::afterSave($object);
$value = $object->getData($this->getAttribute()->getName());
if (is_array($value) && !empty($value['delete'])) {
$object->setData($this->getAttribute()->getName(), '');
$this->getAttribute()->getEntity()->saveAttribute($object, $this->getAttribute()->getName());
return $this;
}
$path = Mage::getBaseDir('media') . DS . 'goodahead' . DS . 'etm' . DS . 'images' . DS . $object->getEntityTypeInstance()->getEntityTypeCode() . DS . $this->getAttribute()->getAttributeCode() . DS;
try {
$uploader = new Varien_File_Uploader($this->getAttribute()->getName());
$uploader->setAllowedExtensions(array('jpg', 'jpeg', 'gif', 'png'));
$uploader->setAllowRenameFiles(true);
$uploader->setAllowCreateFolders(true);
$uploader->setFilesDispersion(true);
$uploader->save($path);
$object->setData($this->getAttribute()->getName(), $uploader->getUploadedFileName());
$this->getAttribute()->getEntity()->saveAttribute($object, $this->getAttribute()->getName());
} catch (Exception $e) {
if ($e->getCode() != Varien_File_Uploader::TMP_NAME_EMPTY) {
Mage::logException($e);
}
/** @TODO ??? */
return $this;
}
return $this;
}
示例7: beforeSave
/**
* Before save method
*
* @param Varien_Object $object Object Model
* @return FireGento_DynamicCategory_Model_Entity_Attribute_Backend_Rule Self.
*/
public function beforeSave($object)
{
parent::beforeSave($object);
$attrCode = $this->getAttribute()->getAttributeCode();
$object->setData($attrCode, serialize($object->getData($attrCode)));
return $this;
}
示例8: afterSave
public function afterSave($object)
{
if ($object->getOrderItem()) {
$object->getOrderItem()->save();
}
return parent::beforeSave($object);
}
示例9: afterSave
public function afterSave($object)
{
parent::afterSave($object);
$object->getItemsCollection()->save();
$object->getShippingRatesCollection()->save();
return $this;
}
示例10: getAttribute
/**
* Get attribute instance
*
* @return Mage_Eav_Model_Entity_Attribute_Abstract
*/
public function getAttribute()
{
if (is_null($this->_attribute)) {
$attribute = Mage::getModel('eav/entity_attribute')->loadByCode('catalog_category', 'virtual_category');
$this->setAttribute($attribute);
}
return parent::getAttribute();
}
示例11: beforeSave
public function beforeSave($object)
{
$data = $object->getData($this->getAttribute()->getAttributeCode());
if (is_array($data)) {
$object->setData($this->getAttribute()->getAttributeCode(), implode(',', $data));
}
return parent::beforeSave($object);
}
示例12: beforeSave
public function beforeSave($object)
{
if ($object->getOrder()) {
$object->setOrderId($object->getOrder()->getId());
$object->setBillingAddressId($object->getOrder()->getBillingAddress()->getId());
}
return parent::beforeSave($object);
}
示例13: beforeSave
public function beforeSave($object)
{
if ($object->getAddress()) {
$object->setParentId($object->getAddress()->getId())->setStoreId($object->getAddress()->getStoreId());
}
parent::beforeSave($object);
return $this;
}
示例14: beforeSave
public function beforeSave($object)
{
if ($object->getOrder()) {
$object->setParentId($object->getOrder()->getId());
}
parent::beforeSave($object);
return $this;
}
示例15: afterSave
public function afterSave($object)
{
parent::afterSave($object);
$object->getAddressesCollection()->save();
$object->getItemsCollection()->save();
$object->getPaymentsCollection()->save();
return $this;
}