当前位置: 首页>>代码示例>>PHP>>正文


PHP AbstractDb::_afterSave方法代码示例

本文整理汇总了PHP中Magento\Framework\Model\Resource\Db\AbstractDb::_afterSave方法的典型用法代码示例。如果您正苦于以下问题:PHP AbstractDb::_afterSave方法的具体用法?PHP AbstractDb::_afterSave怎么用?PHP AbstractDb::_afterSave使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Magento\Framework\Model\Resource\Db\AbstractDb的用法示例。


在下文中一共展示了AbstractDb::_afterSave方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: _afterSave

 /**
  * Perform actions after object save
  *
  * @param \Magento\Framework\Model\AbstractModel $object
  * @return $this
  */
 protected function _afterSave(\Magento\Framework\Model\AbstractModel $object)
 {
     if ($object->getGroups()) {
         /* @var $group \Magento\Eav\Model\Entity\Attribute\Group */
         foreach ($object->getGroups() as $group) {
             $group->setAttributeSetId($object->getId());
             if ($group->itemExists() && !$group->getId()) {
                 continue;
             }
             $group->save();
         }
     }
     if ($object->getRemoveGroups()) {
         foreach ($object->getRemoveGroups() as $group) {
             /* @var $group \Magento\Eav\Model\Entity\Attribute\Group */
             $group->delete();
         }
         $this->_attrGroupFactory->create()->updateDefaultGroup($object->getId());
     }
     if ($object->getRemoveAttributes()) {
         foreach ($object->getRemoveAttributes() as $attribute) {
             /* @var $attribute \Magento\Eav\Model\Entity\Attribute */
             $attribute->deleteEntity();
         }
     }
     return parent::_afterSave($object);
 }
开发者ID:shabbirvividads,项目名称:magento2,代码行数:33,代码来源:Set.php

示例2: _afterSave

 /**
  * Update Store Group data after save store
  *
  * @param \Magento\Framework\Model\AbstractModel $object
  * @return $this
  */
 protected function _afterSave(\Magento\Framework\Model\AbstractModel $object)
 {
     parent::_afterSave($object);
     $this->_updateGroupDefaultStore($object->getGroupId(), $object->getId());
     $this->_changeGroup($object);
     return $this;
 }
开发者ID:shabbirvividads,项目名称:magento2,代码行数:13,代码来源:Store.php

示例3: _afterSave

 /**
  * Perform actions after object save
  *
  * @param \Magento\Widget\Model\Widget\Instance $object
  * @return $this
  */
 protected function _afterSave(AbstractModel $object)
 {
     $pageTable = $this->getTable('widget_instance_page');
     $pageLayoutTable = $this->getTable('widget_instance_page_layout');
     $readAdapter = $this->_getReadAdapter();
     $writeAdapter = $this->_getWriteAdapter();
     $select = $readAdapter->select()->from($pageTable, 'page_id')->where('instance_id = ?', (int) $object->getId());
     $pageIds = $readAdapter->fetchCol($select);
     $removePageIds = array_diff($pageIds, $object->getData('page_group_ids'));
     if (is_array($pageIds) && count($pageIds) > 0) {
         $inCond = $readAdapter->prepareSqlCondition('page_id', ['in' => $pageIds]);
         $select = $readAdapter->select()->from($pageLayoutTable, 'layout_update_id')->where($inCond);
         $removeLayoutUpdateIds = $readAdapter->fetchCol($select);
         $writeAdapter->delete($pageLayoutTable, $inCond);
         $this->_deleteLayoutUpdates($removeLayoutUpdateIds);
     }
     $this->_deleteWidgetInstancePages($removePageIds);
     foreach ($object->getData('page_groups') as $pageGroup) {
         $pageLayoutUpdateIds = $this->_saveLayoutUpdates($object, $pageGroup);
         $data = ['page_group' => $pageGroup['group'], 'layout_handle' => $pageGroup['layout_handle'], 'block_reference' => $pageGroup['block_reference'], 'page_for' => $pageGroup['for'], 'entities' => $pageGroup['entities'], 'page_template' => $pageGroup['template']];
         $pageId = $pageGroup['page_id'];
         if (in_array($pageGroup['page_id'], $pageIds)) {
             $writeAdapter->update($pageTable, $data, ['page_id = ?' => (int) $pageId]);
         } else {
             $writeAdapter->insert($pageTable, array_merge(['instance_id' => $object->getId()], $data));
             $pageId = $writeAdapter->lastInsertId($pageTable);
         }
         foreach ($pageLayoutUpdateIds as $layoutUpdateId) {
             $writeAdapter->insert($pageLayoutTable, ['page_id' => $pageId, 'layout_update_id' => $layoutUpdateId]);
         }
     }
     return parent::_afterSave($object);
 }
开发者ID:vasiljok,项目名称:magento2,代码行数:39,代码来源:Instance.php

示例4: _afterSave

 /**
  * Perform actions after object save
  *
  * @param \Magento\Framework\Model\AbstractModel $object
  * @return $this
  */
 protected function _afterSave(\Magento\Framework\Model\AbstractModel $object)
 {
     if ($object->getIsDefault()) {
         $this->_getWriteAdapter()->update($this->getMainTable(), ['is_default' => 0]);
         $where = ['website_id = ?' => $object->getId()];
         $this->_getWriteAdapter()->update($this->getMainTable(), ['is_default' => 1], $where);
     }
     return parent::_afterSave($object);
 }
开发者ID:nja78,项目名称:magento2,代码行数:15,代码来源:Website.php

示例5: _afterSave

 /**
  * Perform actions after object save
  *
  * @param \Magento\Framework\Model\AbstractModel $object
  * @return \Magento\Framework\Model\Resource\Db\AbstractDb
  */
 protected function _afterSave(\Magento\Framework\Model\AbstractModel $object)
 {
     if ($object->getAttributes()) {
         foreach ($object->getAttributes() as $attribute) {
             $attribute->setAttributeGroupId($object->getId());
             $attribute->save();
         }
     }
     return parent::_afterSave($object);
 }
开发者ID:shabbirvividads,项目名称:magento2,代码行数:16,代码来源:Group.php

示例6: _afterSave

 /**
  * Method to run after save
  *
  * @param \Magento\Framework\Model\AbstractModel $object
  * @return $this
  */
 protected function _afterSave(\Magento\Framework\Model\AbstractModel $object)
 {
     $condition = ['agreement_id = ?' => $object->getId()];
     $this->_getWriteAdapter()->delete($this->getTable('checkout_agreement_store'), $condition);
     foreach ((array) $object->getData('stores') as $store) {
         $storeArray = [];
         $storeArray['agreement_id'] = $object->getId();
         $storeArray['store_id'] = $store;
         $this->_getWriteAdapter()->insert($this->getTable('checkout_agreement_store'), $storeArray);
     }
     return parent::_afterSave($object);
 }
开发者ID:shabbirvividads,项目名称:magento2,代码行数:18,代码来源:Agreement.php

示例7: _afterSave

 /**
  * After save (save labels)
  *
  * @param FormFieldset|AbstractModel $object
  * @return $this
  * @SuppressWarnings(PHPMD.CyclomaticComplexity)
  * @SuppressWarnings(PHPMD.NPathComplexity)
  */
 protected function _afterSave(AbstractModel $object)
 {
     if ($object->hasLabels()) {
         $new = $object->getLabels();
         $old = $this->getLabels($object);
         $adapter = $this->_getWriteAdapter();
         $insert = array_diff(array_keys($new), array_keys($old));
         $delete = array_diff(array_keys($old), array_keys($new));
         $update = [];
         foreach ($new as $storeId => $label) {
             if (isset($old[$storeId]) && $old[$storeId] != $label) {
                 $update[$storeId] = $label;
             } elseif (isset($old[$storeId]) && empty($label)) {
                 $delete[] = $storeId;
             }
         }
         if (!empty($insert)) {
             $data = [];
             foreach ($insert as $storeId) {
                 $label = $new[$storeId];
                 if (empty($label)) {
                     continue;
                 }
                 $data[] = ['fieldset_id' => (int) $object->getId(), 'store_id' => (int) $storeId, 'label' => $label];
             }
             if ($data) {
                 $adapter->insertMultiple($this->getTable('eav_form_fieldset_label'), $data);
             }
         }
         if (!empty($delete)) {
             $where = ['fieldset_id = ?' => $object->getId(), 'store_id IN(?)' => $delete];
             $adapter->delete($this->getTable('eav_form_fieldset_label'), $where);
         }
         if (!empty($update)) {
             foreach ($update as $storeId => $label) {
                 $bind = ['label' => $label];
                 $where = ['fieldset_id =?' => $object->getId(), 'store_id =?' => $storeId];
                 $adapter->update($this->getTable('eav_form_fieldset_label'), $bind, $where);
             }
         }
     }
     return parent::_afterSave($object);
 }
开发者ID:shabbirvividads,项目名称:magento2,代码行数:51,代码来源:Fieldset.php

示例8: _afterSave

 /**
  * After save process
  *
  * @param \Magento\Framework\Model\AbstractModel $object
  * @return $this
  */
 protected function _afterSave(\Magento\Framework\Model\AbstractModel $object)
 {
     parent::_afterSave($object);
     $condition = array('option_id = ?' => $object->getId(), 'store_id = ? OR store_id = 0' => $object->getStoreId());
     $write = $this->_getWriteAdapter();
     $write->delete($this->getTable('catalog_product_bundle_option_value'), $condition);
     $data = new \Magento\Framework\Object();
     $data->setOptionId($object->getId())->setStoreId($object->getStoreId())->setTitle($object->getTitle());
     $write->insert($this->getTable('catalog_product_bundle_option_value'), $data->getData());
     /**
      * also saving default value if this store view scope
      */
     if ($object->getStoreId()) {
         $data->setStoreId(0);
         $data->setTitle($object->getDefaultTitle());
         $write->insert($this->getTable('catalog_product_bundle_option_value'), $data->getData());
     }
     return $this;
 }
开发者ID:aiesh,项目名称:magento2,代码行数:25,代码来源:Option.php

示例9: _afterSave

 /**
  * After save
  *
  * @param \Magento\Framework\Model\AbstractModel $object
  * @return $this
  */
 protected function _afterSave(\Magento\Framework\Model\AbstractModel $object)
 {
     $adapter = $this->_getWriteAdapter();
     $select = $adapter->select()->from($this->getMainTable(), array('store_id', 'key_id'))->where('string = :string');
     $stores = $adapter->fetchPairs($select, array('string' => $object->getString()));
     $translations = $object->getStoreTranslations();
     if (is_array($translations)) {
         foreach ($translations as $storeId => $translate) {
             if (is_null($translate) || $translate == '') {
                 $where = array('store_id = ?' => $storeId, 'string = ?' => $object->getString());
                 $adapter->delete($this->getMainTable(), $where);
             } else {
                 $data = array('store_id' => $storeId, 'string' => $object->getString(), 'translate' => $translate);
                 if (isset($stores[$storeId])) {
                     $adapter->update($this->getMainTable(), $data, array('key_id = ?' => $stores[$storeId]));
                 } else {
                     $adapter->insert($this->getMainTable(), $data);
                 }
             }
         }
     }
     return parent::_afterSave($object);
 }
开发者ID:aiesh,项目名称:magento2,代码行数:29,代码来源:String.php

示例10: _afterSave

 /**
  * Reindex CatalogInventory save event
  *
  * @param AbstractModel $object
  * @return $this
  */
 protected function _afterSave(AbstractModel $object)
 {
     parent::_afterSave($object);
     /** @var StockItemInterface $object */
     if ($this->processIndexEvents) {
         $this->stockIndexerProcessor->markIndexerAsInvalid();
         $this->stockIndexerProcessor->reindexRow($object->getProductId());
     }
     return $this;
 }
开发者ID:niranjanssiet,项目名称:magento2,代码行数:16,代码来源:Item.php

示例11: _afterSave

 /**
  * Save entity types after save form type
  *
  * @see \Magento\Framework\Model\Resource\Db\AbstractDb#_afterSave($object)
  *
  * @param FormType|AbstractModel $object
  * @return $this
  */
 protected function _afterSave(AbstractModel $object)
 {
     if ($object->hasEntityTypes()) {
         $new = $object->getEntityTypes();
         $old = $this->getEntityTypes($object);
         $insert = array_diff($new, $old);
         $delete = array_diff($old, $new);
         $adapter = $this->_getWriteAdapter();
         if (!empty($insert)) {
             $data = array();
             foreach ($insert as $entityId) {
                 if (empty($entityId)) {
                     continue;
                 }
                 $data[] = array('entity_type_id' => (int) $entityId, 'type_id' => $object->getId());
             }
             if ($data) {
                 $adapter->insertMultiple($this->getTable('eav_form_type_entity'), $data);
             }
         }
         if (!empty($delete)) {
             $where = array('entity_type_id IN (?)' => $delete, 'type_id = ?' => $object->getId());
             $adapter->delete($this->getTable('eav_form_type_entity'), $where);
         }
     }
     return parent::_afterSave($object);
 }
开发者ID:aiesh,项目名称:magento2,代码行数:35,代码来源:Type.php

示例12: _afterSave

 /**
  * Actions after save
  *
  * @param \Magento\Framework\Model\AbstractModel|\Magento\Review\Model\Rating $object
  * @return $this
  */
 protected function _afterSave(\Magento\Framework\Model\AbstractModel $object)
 {
     parent::_afterSave($object);
     $adapter = $this->_getWriteAdapter();
     $ratingId = (int) $object->getId();
     if ($object->hasRatingCodes()) {
         $ratingTitleTable = $this->getTable('rating_title');
         $adapter->beginTransaction();
         try {
             $select = $adapter->select()->from($ratingTitleTable, array('store_id', 'value'))->where('rating_id = :rating_id');
             $old = $adapter->fetchPairs($select, array(':rating_id' => $ratingId));
             $new = array_filter(array_map('trim', $object->getRatingCodes()));
             $insert = array_diff_assoc($new, $old);
             $delete = array_diff_assoc($old, $new);
             if (!empty($delete)) {
                 $where = array('rating_id = ?' => $ratingId, 'store_id IN(?)' => array_keys($delete));
                 $adapter->delete($ratingTitleTable, $where);
             }
             if ($insert) {
                 $data = array();
                 foreach ($insert as $storeId => $title) {
                     $data[] = array('rating_id' => $ratingId, 'store_id' => (int) $storeId, 'value' => $title);
                 }
                 if (!empty($data)) {
                     $adapter->insertMultiple($ratingTitleTable, $data);
                 }
             }
             $adapter->commit();
         } catch (\Exception $e) {
             $this->_logger->logException($e);
             $adapter->rollBack();
         }
     }
     if ($object->hasStores()) {
         $ratingStoreTable = $this->getTable('rating_store');
         $adapter->beginTransaction();
         try {
             $select = $adapter->select()->from($ratingStoreTable, array('store_id'))->where('rating_id = :rating_id');
             $old = $adapter->fetchCol($select, array(':rating_id' => $ratingId));
             $new = $object->getStores();
             $insert = array_diff($new, $old);
             $delete = array_diff($old, $new);
             if ($delete) {
                 $where = array('rating_id = ?' => $ratingId, 'store_id IN(?)' => $delete);
                 $adapter->delete($ratingStoreTable, $where);
             }
             if ($insert) {
                 $data = array();
                 foreach ($insert as $storeId) {
                     $data[] = array('rating_id' => $ratingId, 'store_id' => (int) $storeId);
                 }
                 $adapter->insertMultiple($ratingStoreTable, $data);
             }
             $adapter->commit();
         } catch (\Exception $e) {
             $this->_logger->logException($e);
             $adapter->rollBack();
         }
     }
     return $this;
 }
开发者ID:pavelnovitsky,项目名称:magento2,代码行数:67,代码来源:Rating.php

示例13: _afterSave

 /**
  * Actions after save
  *
  * @param \Magento\Framework\Model\AbstractModel|\Magento\Review\Model\Rating $object
  * @return $this
  */
 protected function _afterSave(\Magento\Framework\Model\AbstractModel $object)
 {
     parent::_afterSave($object);
     if ($object->hasRatingCodes()) {
         $this->processRatingCodes($object);
     }
     if ($object->hasStores()) {
         $this->processRatingStores($object);
     }
     return $this;
 }
开发者ID:nja78,项目名称:magento2,代码行数:17,代码来源:Rating.php

示例14: _afterSave

 /**
  * Save assigned processes
  *
  * @param \Magento\Framework\Model\AbstractModel $object
  * @return $this
  */
 protected function _afterSave(AbstractModel $object)
 {
     $processIds = $object->getProcessIds();
     if (is_array($processIds)) {
         $processTable = $this->getTable('index_process_event');
         if (empty($processIds)) {
             $this->_getWriteAdapter()->delete($processTable);
         } else {
             foreach ($processIds as $processId => $processStatus) {
                 if (is_null($processStatus) || $processStatus == ProcessModel::EVENT_STATUS_DONE) {
                     $this->_getWriteAdapter()->delete($processTable, array('process_id = ?' => $processId, 'event_id = ?' => $object->getId()));
                     continue;
                 }
                 $data = array('process_id' => $processId, 'event_id' => $object->getId(), 'status' => $processStatus);
                 $this->_getWriteAdapter()->insertOnDuplicate($processTable, $data, array('status'));
             }
         }
     }
     return parent::_afterSave($object);
 }
开发者ID:aiesh,项目名称:magento2,代码行数:26,代码来源:Event.php

示例15: _afterSave

 /**
  * Proceed operations after object is saved
  * Save options store data
  *
  * @param \Magento\Framework\Model\AbstractModel $object
  * @return \Magento\Framework\Model\Resource\Db\AbstractDb
  */
 protected function _afterSave(\Magento\Framework\Model\AbstractModel $object)
 {
     $this->_saveValuePrices($object);
     $this->_saveValueTitles($object);
     return parent::_afterSave($object);
 }
开发者ID:Atlis,项目名称:docker-magento2,代码行数:13,代码来源:Value.php


注:本文中的Magento\Framework\Model\Resource\Db\AbstractDb::_afterSave方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。