本文整理匯總了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
*/
protected function _beforeSave()
{
try {
$this->attrLockValidator->validate($this);
} catch (\Magento\Framework\Model\Exception $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\Model\Exception
*/
protected function _beforeSave()
{
$this->setData('modulePrefix', self::MODULE_NAME);
if (isset($this->_origData['is_global'])) {
if (!isset($this->_data['is_global'])) {
$this->_data['is_global'] = self::SCOPE_GLOBAL;
}
if ($this->_data['is_global'] != $this->_origData['is_global']) {
try {
$this->attrLockValidator->validate($this);
} catch (\Magento\Framework\Model\Exception $exception) {
throw new \Magento\Framework\Model\Exception(__('Do not change the scope. ' . $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);
}
}
return parent::_beforeSave();
}