本文整理汇总了PHP中Magento\Framework\Model\AbstractModel::afterSave方法的典型用法代码示例。如果您正苦于以下问题:PHP AbstractModel::afterSave方法的具体用法?PHP AbstractModel::afterSave怎么用?PHP AbstractModel::afterSave使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Magento\Framework\Model\AbstractModel
的用法示例。
在下文中一共展示了AbstractModel::afterSave方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: testUpdateStoredData
public function testUpdateStoredData()
{
$this->model->setData(['id' => 1000, 'name' => 'Test Name']);
$this->assertEmpty($this->model->getStoredData());
$this->model->afterLoad();
$this->assertEquals($this->model->getData(), $this->model->getStoredData());
$this->model->setData('value', 'Test Value');
$this->model->afterSave();
$this->assertEquals($this->model->getData(), $this->model->getStoredData());
$this->model->afterDelete();
$this->assertEmpty($this->model->getStoredData());
}
示例2: afterSave
public function afterSave()
{
if ($storeViewId = $this->getStoreViewId()) {
$storeAttributes = $this->getStoreAttributes();
foreach ($storeAttributes as $attribute) {
$attributeValue = $this->_valueFactory->create()->loadAttributeValue($this->getId(), $storeViewId, $attribute);
if ($this->getData($attribute . '_in_store')) {
try {
if ($attribute == 'image' && $this->getData('delete_image')) {
$attributeValue->delete();
} else {
$attributeValue->setValue($this->getData($attribute . '_value'))->save();
}
} catch (\Exception $e) {
$this->_monolog->addError($e->getMessage());
}
} elseif ($attributeValue && $attributeValue->getId()) {
try {
$attributeValue->delete();
} catch (\Exception $e) {
$this->_monolog->addError($e->getMessage());
}
}
}
}
return parent::afterSave();
}
示例3: afterSave
/**
* The "After save" actions
*
* @return $this
*/
public function afterSave()
{
parent::afterSave();
if ($this->_oauthData->isCleanupProbability()) {
$this->getResource()->deleteOldEntries($this->_oauthData->getCleanupExpirationPeriod());
}
return $this;
}
示例4: afterSave
/**
* Processing object before save data
*
* @return $this
*/
public function afterSave()
{
if (!$this->_catalogData->isPriceGlobal() && $this->getWebsiteId()) {
$this->getResource()->saveSelectionPrice($this);
if (!$this->getDefaultPriceScope()) {
$this->unsSelectionPriceValue();
$this->unsSelectionPriceType();
}
}
parent::afterSave();
}
示例5: afterSave
/**
* Process data after model is saved
*
* @return $this
*/
public function afterSave()
{
$this->_role = null;
return parent::afterSave();
}
示例6: afterSave
/**
* Save item options after item saved
*
* @return $this
*/
public function afterSave()
{
$this->saveItemOptions();
return parent::afterSave();
}
示例7: afterSave
/**
* Invalidate related cache if instance contain layout updates
*
* @return $this
*/
public function afterSave()
{
if ($this->dataHasChangedFor('page_groups') || $this->dataHasChangedFor('widget_parameters')) {
$this->_invalidateCache();
}
return parent::afterSave();
}
示例8: afterSave
/**
* Process after save operations
*
* @return $this
*/
public function afterSave()
{
parent::afterSave();
$this->invalidateIndex();
return $this;
}
示例9: afterSave
/**
* {@inheritdoc}
*
* {@inheritdoc}. In addition, it sets status 'invalidate' for config caches
*
* @return $this
*/
public function afterSave()
{
if ($this->isValueChanged()) {
$this->cacheTypeList->invalidate(\Magento\Framework\App\Cache\Type\Config::TYPE_IDENTIFIER);
}
return parent::afterSave();
}
示例10: afterSave
/**
* Processing object's after save. Overriden to prevent invalidation of "config" cache tag.
*
* @SuppressWarnings(PHPMD.StaticAccess)
*
* @return $this
*/
public function afterSave()
{
return \Magento\Framework\Model\AbstractModel::afterSave();
}
示例11: afterSave
/**
* Save related items
*
* @return $this
*/
public function afterSave()
{
parent::afterSave();
if (null !== $this->_itemCollection) {
$this->getItemCollection()->save();
}
return $this;
}
示例12: afterSave
/**
* Processing object after save data
*
* @return $this
*/
public function afterSave()
{
$indexer = $this->indexerRegistry->get(self::CUSTOMER_GRID_INDEXER_ID);
if ($indexer->getState()->getStatus() == StateInterface::STATUS_VALID) {
$this->_getResource()->addCommitCallback([$this, 'reindex']);
}
return parent::afterSave();
}
示例13: afterSave
/**
* @return AbstractModel
* @throws \Magento\Framework\Exception\LocalizedException
*/
public function afterSave()
{
$this->getValueInstance()->unsetValues();
if (is_array($this->getData('values'))) {
foreach ($this->getData('values') as $value) {
$this->getValueInstance()->addValue($value);
}
$this->getValueInstance()->setOption($this)->saveValues();
} elseif ($this->getGroupByType($this->getType()) == self::OPTION_GROUP_SELECT) {
throw new LocalizedException(__('Select type options required values rows.'));
}
return parent::afterSave();
}
示例14: afterSave
/**
* {@inheritdoc}
*/
public function afterSave()
{
$customerData = (array) $this->getData();
$customerData[CustomerData::ID] = $this->getId();
$dataObject = $this->customerDataFactory->create();
$this->dataObjectHelper->populateWithArray($dataObject, $customerData, '\\Magento\\Customer\\Api\\Data\\CustomerInterface');
$customerOrigData = (array) $this->getOrigData();
$customerOrigData[CustomerData::ID] = $this->getId();
$origDataObject = $this->customerDataFactory->create();
$this->dataObjectHelper->populateWithArray($origDataObject, $customerOrigData, '\\Magento\\Customer\\Api\\Data\\CustomerInterface');
$this->_eventManager->dispatch('customer_save_after_data_object', ['customer_data_object' => $dataObject, 'orig_customer_data_object' => $origDataObject]);
return parent::afterSave();
}
示例15: afterSave
/**
* {@inheritdoc}
* @return $this
*/
public function afterSave()
{
$this->getIndexInstance()->afterModelSave();
return parent::afterSave();
}