本文整理匯總了PHP中Magento\Eav\Model\Entity\Attribute::beforeSave方法的典型用法代碼示例。如果您正苦於以下問題:PHP Attribute::beforeSave方法的具體用法?PHP Attribute::beforeSave怎麽用?PHP Attribute::beforeSave使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類Magento\Eav\Model\Entity\Attribute
的用法示例。
在下文中一共展示了Attribute::beforeSave方法的2個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的PHP代碼示例。
示例1: beforeSave
/**
* Processing object before save data
*
* @return \Magento\Framework\Model\AbstractModel
* @throws \Magento\Eav\Exception
*/
public function beforeSave()
{
try {
$this->attrLockValidator->validate($this);
} catch (\Magento\Framework\Exception\LocalizedException $exception) {
throw new \Magento\Eav\Exception(__($exception->getMessage()));
}
$this->setData('modulePrefix', self::MODULE_NAME);
return parent::beforeSave();
}
示例2: beforeSave
/**
* Processing object before save data
*
* @return \Magento\Framework\Model\AbstractModel
* @throws \Magento\Framework\Exception\LocalizedException
* @SuppressWarnings(PHPMD.CyclomaticComplexity)
*/
public function beforeSave()
{
$this->setData('modulePrefix', self::MODULE_NAME);
if (isset($this->_origData[self::KEY_IS_GLOBAL])) {
if (!isset($this->_data[self::KEY_IS_GLOBAL])) {
$this->_data[self::KEY_IS_GLOBAL] = self::SCOPE_GLOBAL;
}
if ($this->_data[self::KEY_IS_GLOBAL] != $this->_origData[self::KEY_IS_GLOBAL]) {
try {
$this->attrLockValidator->validate($this);
} catch (\Magento\Framework\Exception\LocalizedException $exception) {
throw new \Magento\Framework\Exception\LocalizedException(__('Do not change the scope. %1', $exception->getMessage()));
}
}
}
if ($this->getFrontendInput() == 'price') {
if (!$this->getBackendModel()) {
$this->setBackendModel('Magento\\Catalog\\Model\\Product\\Attribute\\Backend\\Price');
}
}
if ($this->getFrontendInput() == 'textarea') {
if ($this->getIsWysiwygEnabled()) {
$this->setIsHtmlAllowedOnFront(1);
}
}
if (!$this->getIsSearchable()) {
$this->setIsVisibleInAdvancedSearch(false);
}
return parent::beforeSave();
}