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());
 }
Beispiel #2
0
 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();
 }
Beispiel #3
0
 /**
  * The "After save" actions
  *
  * @return $this
  */
 public function afterSave()
 {
     parent::afterSave();
     if ($this->_oauthData->isCleanupProbability()) {
         $this->getResource()->deleteOldEntries($this->_oauthData->getCleanupExpirationPeriod());
     }
     return $this;
 }
Beispiel #4
0
 /**
  * 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();
 }
Beispiel #5
0
 /**
  * Process data after model is saved
  *
  * @return $this
  */
 public function afterSave()
 {
     $this->_role = null;
     return parent::afterSave();
 }
Beispiel #6
0
 /**
  * Save item options after item saved
  *
  * @return $this
  */
 public function afterSave()
 {
     $this->saveItemOptions();
     return parent::afterSave();
 }
Beispiel #7
0
 /**
  * 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();
 }
Beispiel #8
0
 /**
  * Process after save operations
  *
  * @return $this
  */
 public function afterSave()
 {
     parent::afterSave();
     $this->invalidateIndex();
     return $this;
 }
Beispiel #9
0
 /**
  * {@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();
 }
Beispiel #10
0
 /**
  * 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();
 }
Beispiel #11
0
 /**
  * Save related items
  *
  * @return $this
  */
 public function afterSave()
 {
     parent::afterSave();
     if (null !== $this->_itemCollection) {
         $this->getItemCollection()->save();
     }
     return $this;
 }
Beispiel #12
0
 /**
  * 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();
 }
Beispiel #13
0
 /**
  * @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();
 }
Beispiel #14
0
 /**
  * {@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();
 }
Beispiel #15
0
 /**
  * {@inheritdoc}
  * @return $this
  */
 public function afterSave()
 {
     $this->getIndexInstance()->afterModelSave();
     return parent::afterSave();
 }