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()); }
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(); }
/** * The "After save" actions * * @return $this */ public function afterSave() { parent::afterSave(); if ($this->_oauthData->isCleanupProbability()) { $this->getResource()->deleteOldEntries($this->_oauthData->getCleanupExpirationPeriod()); } return $this; }
/** * 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(); }
/** * Process data after model is saved * * @return $this */ public function afterSave() { $this->_role = null; return parent::afterSave(); }
/** * Save item options after item saved * * @return $this */ public function afterSave() { $this->saveItemOptions(); return parent::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(); }
/** * Process after save operations * * @return $this */ public function afterSave() { parent::afterSave(); $this->invalidateIndex(); return $this; }
/** * {@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(); }
/** * 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(); }
/** * Save related items * * @return $this */ public function afterSave() { parent::afterSave(); if (null !== $this->_itemCollection) { $this->getItemCollection()->save(); } return $this; }
/** * 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(); }
/** * @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(); }
/** * {@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(); }
/** * {@inheritdoc} * @return $this */ public function afterSave() { $this->getIndexInstance()->afterModelSave(); return parent::afterSave(); }