本文整理汇总了PHP中Mage_Eav_Model_Entity_Attribute_Backend_Abstract::beforeSave方法的典型用法代码示例。如果您正苦于以下问题:PHP Mage_Eav_Model_Entity_Attribute_Backend_Abstract::beforeSave方法的具体用法?PHP Mage_Eav_Model_Entity_Attribute_Backend_Abstract::beforeSave怎么用?PHP Mage_Eav_Model_Entity_Attribute_Backend_Abstract::beforeSave使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Mage_Eav_Model_Entity_Attribute_Backend_Abstract
的用法示例。
在下文中一共展示了Mage_Eav_Model_Entity_Attribute_Backend_Abstract::beforeSave方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: 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
示例2: 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);
}
示例3: afterSave
public function afterSave($object)
{
if ($object->getOrderItem()) {
$object->getOrderItem()->save();
}
return parent::beforeSave($object);
}
示例4: 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);
}
示例5: beforeSave
/**
* Process the attribute value before saving
*
* @param Mage_Core_Model_Abstract $object
* @return Mage_Eav_Model_Entity_Attribute_Backend_Abstract
*/
public function beforeSave($object)
{
$attributeCode = $this->getAttribute()->getAttributeCode();
$data = $object->getData($attributeCode);
$customerGroupIds = array(Netzarbeiter_GroupsCatalog2_Helper_Data::USE_DEFAULT, Netzarbeiter_GroupsCatalog2_Helper_Data::USE_NONE);
$customerGroups = Mage::helper('netzarbeiter_groupscatalog2')->getGroups();
$customerGroupIds = array_merge($customerGroupIds, array_keys($customerGroups->getItems()));
if (!$data) {
$data = array(Netzarbeiter_GroupsCatalog2_Helper_Data::USE_DEFAULT);
}
if (!is_array($data)) {
$data = explode(',', $data);
}
if (1 < count($data)) {
// remove USE_DEFAULT if any other groups are selected, too
$key = array_search(Netzarbeiter_GroupsCatalog2_Helper_Data::USE_DEFAULT, $data);
if (false !== $key) {
unset($data[$key]);
}
// if USE_NONE is selected remove all other groups
if (in_array(Netzarbeiter_GroupsCatalog2_Helper_Data::USE_NONE, $data)) {
$data = array(Netzarbeiter_GroupsCatalog2_Helper_Data::USE_NONE);
}
}
// validate all customer groups ids are valid
foreach ($data as $key => $groupId) {
if (!in_array($groupId, $customerGroupIds)) {
unset($data[$key]);
}
}
// I like it nice and tidy, this gives us sequential index numbers again as a side effect :)
sort($data);
$object->setData($attributeCode, implode(',', $data));
return parent::beforeSave($object);
}
示例6: 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;
}
示例7: beforeSave
public function beforeSave($object)
{
if ($object->getOrder()) {
$object->setParentId($object->getOrder()->getId());
}
parent::beforeSave($object);
return $this;
}
示例8: beforeSave
public function beforeSave($object)
{
if ($object->getAddress()) {
$object->setParentId($object->getAddress()->getId())->setStoreId($object->getAddress()->getStoreId());
}
parent::beforeSave($object);
return $this;
}
示例9: beforeSave
public function beforeSave($object)
{
if ($object->getOrder()) {
$object->setOrderId($object->getOrder()->getId());
$object->setBillingAddressId($object->getOrder()->getBillingAddress()->getId());
}
return parent::beforeSave($object);
}
示例10: 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);
}
示例11: beforeSave
/**
* Prepare data for save
*
* @param Varien_Object $object
* @return Mage_Eav_Model_Entity_Attribute_Backend_Abstract
*/
public function beforeSave($object)
{
$attributeCode = $this->getAttribute()->getAttributeCode();
$data = $object->getData($attributeCode);
if (is_array($data)) {
$data = array_filter($data);
$object->setData($attributeCode, implode(',', $data));
}
return parent::beforeSave($object);
}
示例12: beforeSave
/**
* Prepare data for save
*
* @param Varien_Object $object
* @return Mage_Eav_Model_Entity_Attribute_Backend_Abstract
*/
public function beforeSave($object)
{
$attributeCode = $this->getAttribute()->getAttributeCode();
$data = $object->getData($attributeCode);
if ($data instanceof Varien_Object) {
$data = get_class($data) . '|' . json_encode($data->getData());
}
$object->setData($attributeCode, $data);
return parent::beforeSave($object);
}
示例13: beforeSave
/**
* Encrypts the value before saving
*
* @param Mage_Core_Model_Abstract $object Object
* @return Itabs_Debit_Model_Entity_Customer_Attribute_Backend_Encrypted
*/
public function beforeSave($object)
{
$helper = Mage::helper('core');
$attributeName = $this->getAttribute()->getName();
if ($object->getData($attributeName) != '') {
$value = $helper->encrypt($object->getData($attributeName));
$object->setData($attributeName, $value);
}
return parent::beforeSave($object);
}
示例14: beforeSave
/**
* Prepare inventory data from custom atribute
*
* @param Varien_Object $object
* @return Mage_Eav_Model_Entity_Attribute_Backend_Abstract|void
*/
public function beforeSave($object)
{
/** @var $object Mage_Catalog_Model_Product */
$stockData = $object->getData($this->getAttribute()->getAttributeCode());
if ($object->getStockData() !== null || $stockData !== null) {
$object->setStockData(array_replace((array) $object->getStockData(), (array) $stockData));
}
$object->unsetData($this->getAttribute()->getAttributeCode());
parent::beforeSave($object);
}
示例15: beforeSave
public function beforeSave($object)
{
$attrCode = $this->getAttribute()->getAttributeCode();
if ($object->hasData($attrCode)) {
$value = trim($object->getData($attrCode));
if ('' !== $value) {
if (!preg_match('#^(?:http|https|ftp)://[a-z][a-z.]*\\.[a-z]+#', $value)) {
throw new RuntimeException($this->getHelper()->__('Please specify a full URL including http://, https:// or ftp:// for for the attribute "%s"', $this->getAttribute()->getFrontendLabel()));
//Mage::throwException($this->getHelper()->__('Please specify a full URL.'));
}
}
}
return parent::beforeSave($object);
}