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