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


PHP AbstractDb::_afterSave方法代码示例

本文整理汇总了PHP中Magento\Framework\Model\ResourceModel\Db\AbstractDb::_afterSave方法的典型用法代码示例。如果您正苦于以下问题:PHP AbstractDb::_afterSave方法的具体用法?PHP AbstractDb::_afterSave怎么用?PHP AbstractDb::_afterSave使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Magento\Framework\Model\ResourceModel\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:pradeep-wagento,项目名称: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:mrbadao,项目名称:magento-ce,代码行数: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');
     $connection = $this->getConnection();
     $select = $connection->select()->from($pageTable, 'page_id')->where('instance_id = ?', (int) $object->getId());
     $pageIds = $connection->fetchCol($select);
     $removePageIds = array_diff($pageIds, $object->getData('page_group_ids'));
     if (is_array($pageIds) && count($pageIds) > 0) {
         $inCond = $connection->prepareSqlCondition('page_id', ['in' => $pageIds]);
         $select = $connection->select()->from($pageLayoutTable, 'layout_update_id')->where($inCond);
         $removeLayoutUpdateIds = $connection->fetchCol($select);
         $connection->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)) {
             $connection->update($pageTable, $data, ['page_id = ?' => (int) $pageId]);
         } else {
             $connection->insert($pageTable, array_merge(['instance_id' => $object->getId()], $data));
             $pageId = $connection->lastInsertId($pageTable);
         }
         foreach ($pageLayoutUpdateIds as $layoutUpdateId) {
             $connection->insert($pageLayoutTable, ['page_id' => $pageId, 'layout_update_id' => $layoutUpdateId]);
         }
     }
     return parent::_afterSave($object);
 }
开发者ID:pradeep-wagento,项目名称:magento2,代码行数:38,代码来源:Instance.php

示例4: _afterSave

 /**
  * Saves thesaurus linking to terms and stores after save
  *
  * @SuppressWarnings(PHPMD.CamelCaseMethodName)
  *
  * @param \Magento\Framework\Model\AbstractModel $object Thesaurus to save
  *
  * @return $this
  */
 protected function _afterSave(\Magento\Framework\Model\AbstractModel $object)
 {
     parent::_afterSave($object);
     $this->saveStoreRelation($object);
     $this->saveTermsRelation($object);
     return $this;
 }
开发者ID:smile-sa,项目名称:elasticsuite,代码行数:16,代码来源:Thesaurus.php

示例5: _afterSave

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

示例6: _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->getConnection()->update($this->getMainTable(), ['is_default' => 0]);
         $where = ['website_id = ?' => $object->getId()];
         $this->getConnection()->update($this->getMainTable(), ['is_default' => 1], $where);
     }
     return parent::_afterSave($object);
 }
开发者ID:kidaa30,项目名称:magento2-platformsh,代码行数:15,代码来源:Website.php

示例7: _afterSave

 /**
  * Perform actions after object save
  *
  * @param \Magento\Framework\Model\AbstractModel $object
  * @return \Magento\Framework\Model\ResourceModel\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:pradeep-wagento,项目名称:magento2,代码行数:16,代码来源:Group.php

示例8: _afterSave

 protected function _afterSave(\Magento\Framework\Model\AbstractModel $object)
 {
     // TODO test it on magento 2.0
     // fix for Varien\Db\Adapter\Pdo\Mysql::prepareColumnValue
     // an empty string cannot be saved -> NULL is saved instead
     // for Magento version > 1.6.x.x
     foreach ($object->getData() as $key => $value) {
         if ($value instanceof \Zend_Db_Expr && $value->__toString() === '\'\'') {
             $object->setData($key, '');
         }
     }
     return parent::_afterSave($object);
 }
开发者ID:Doability,项目名称:magento2dev,代码行数:13,代码来源:AbstractDb.php

示例9: _afterSave

 protected function _afterSave(\Magento\Framework\Model\AbstractModel $object)
 {
     parent::_afterSave($object);
     // now save the package items
     $this->getConnection()->delete($this->getTable('shipperhq_order_package_items'), ['package_id = ?' => $object->getId()]);
     foreach ((array) $object->getData('items') as $item) {
         if (is_object($item)) {
             $item = (array) $item;
         }
         $itemArray = ['package_id' => $object->getId(), 'sku' => $item['sku'], 'weight_packed' => $item['weight_packed'], 'qty_packed' => $item['qty_packed']];
         $this->getConnection()->insert($this->getTable('shipperhq_order_package_items'), $itemArray);
     }
     return $this;
 }
开发者ID:shipperhq,项目名称:module-shipper,代码行数:14,代码来源:Packages.php

示例10: _afterSave

 /**
  * Perform actions after object save
  *
  * @param \Magento\Framework\Model\AbstractModel $object
  * @return $this
  */
 protected function _afterSave(\Magento\Framework\Model\AbstractModel $object)
 {
     parent::_afterSave($object);
     if ($object->getUseDefaultValue()) {
         /*
          * remove store value
          */
         $this->getConnection()->delete($this->getTable('variable_value'), ['variable_id = ?' => $object->getId(), 'store_id = ?' => $object->getStoreId()]);
     } else {
         $data = ['variable_id' => $object->getId(), 'store_id' => $object->getStoreId(), 'plain_value' => $object->getPlainValue(), 'html_value' => $object->getHtmlValue()];
         $data = $this->_prepareDataForTable(new \Magento\Framework\DataObject($data), $this->getTable('variable_value'));
         $this->getConnection()->insertOnDuplicate($this->getTable('variable_value'), $data, ['plain_value', 'html_value']);
     }
     return $this;
 }
开发者ID:pradeep-wagento,项目名称:magento2,代码行数:21,代码来源:Variable.php

示例11: _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);
         $connection = $this->getConnection();
         $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) {
                 $connection->insertMultiple($this->getTable('eav_form_fieldset_label'), $data);
             }
         }
         if (!empty($delete)) {
             $where = ['fieldset_id = ?' => $object->getId(), 'store_id IN(?)' => $delete];
             $connection->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];
                 $connection->update($this->getTable('eav_form_fieldset_label'), $bind, $where);
             }
         }
     }
     return parent::_afterSave($object);
 }
开发者ID:tingyeeh,项目名称:magento2,代码行数:51,代码来源:Fieldset.php

示例12: _afterSave

 /**
  * After save process
  *
  * @param \Magento\Framework\Model\AbstractModel $object
  * @return $this
  */
 protected function _afterSave(\Magento\Framework\Model\AbstractModel $object)
 {
     parent::_afterSave($object);
     $condition = ['option_id = ?' => $object->getId(), 'store_id = ? OR store_id = 0' => $object->getStoreId()];
     $connection = $this->getConnection();
     $connection->delete($this->getTable('catalog_product_bundle_option_value'), $condition);
     $data = new \Magento\Framework\DataObject();
     $data->setOptionId($object->getId())->setStoreId($object->getStoreId())->setTitle($object->getTitle());
     $connection->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());
         $connection->insert($this->getTable('catalog_product_bundle_option_value'), $data->getData());
     }
     return $this;
 }
开发者ID:Doability,项目名称:magento2dev,代码行数:25,代码来源:Option.php

示例13: _afterSave

 /**
  * Perform operations after object save
  *
  * @param \Magento\Framework\Model\AbstractModel $object
  * @return $this
  */
 protected function _afterSave(\Magento\Framework\Model\AbstractModel $object)
 {
     $oldStores = $this->lookupStoreIds($object->getId());
     $newStores = (array) $object->getStores();
     $table = $this->getTable('swissup_easytabs_store');
     $insert = array_diff($newStores, $oldStores);
     $delete = array_diff($oldStores, $newStores);
     if ($delete) {
         $where = ['tab_id = ?' => (int) $object->getId(), 'store_id IN (?)' => $delete];
         $this->getConnection()->delete($table, $where);
     }
     if ($insert) {
         $data = [];
         foreach ($insert as $storeId) {
             $data[] = ['tab_id' => (int) $object->getId(), 'store_id' => (int) $storeId];
         }
         $this->getConnection()->insertMultiple($table, $data);
     }
     return parent::_afterSave($object);
 }
开发者ID:swissup,项目名称:easytabs,代码行数:26,代码来源:Entity.php

示例14: _afterSave

 /**
  * Assign page to store views
  *
  * @param \Magento\Framework\Model\AbstractModel $object
  * @return $this
  */
 protected function _afterSave(\Magento\Framework\Model\AbstractModel $object)
 {
     $oldProductIds = $this->lookupProductIds($object->getId());
     $newProductIds = array_filter(array_unique($this->getProductIds($object->getData('product_id'))));
     $table = $this->getTable('kuzman_product_faq_id');
     $insert = array_diff($newProductIds, $oldProductIds);
     $delete = array_diff($oldProductIds, $newProductIds);
     if ($delete) {
         $where = ['question_id = ?' => (int) $object->getId(), 'product_id IN (?)' => $delete];
         $this->getConnection()->delete($table, $where);
     }
     if ($insert) {
         $data = [];
         foreach ($insert as $storeId) {
             $data[] = ['question_id' => (int) $object->getId(), 'product_id' => (int) $storeId];
         }
         $this->getConnection()->insertMultiple($table, $data);
     }
     return parent::_afterSave($object);
 }
开发者ID:vladankuzmanovic,项目名称:ProductFaq,代码行数:26,代码来源:Question.php

示例15: _afterSave

 /**
  * Assign post to store views, categories, related posts, etc.
  *
  * @param \Magento\Framework\Model\AbstractModel $object
  * @return $this
  */
 protected function _afterSave(\Magento\Framework\Model\AbstractModel $object)
 {
     $oldIds = $this->lookupStoreIds($object->getId());
     $newIds = (array) $object->getStores();
     if (empty($newIds)) {
         $newIds = (array) $object->getStoreId();
     }
     $this->_updateLinks($object, $newIds, $oldIds, 'magefan_blog_post_store', 'store_id');
     $newIds = (array) $object->getCategories();
     if (is_array($newIds)) {
         $oldIds = $this->lookupCategoryIds($object->getId());
         $this->_updateLinks($object, $newIds, $oldIds, 'magefan_blog_post_category', 'category_id');
     }
     $newIds = $object->getRelatedPostIds();
     if (is_array($newIds)) {
         $oldIds = $this->lookupRelatedPostIds($object->getId());
         $this->_updateLinks($object, $newIds, $oldIds, 'magefan_blog_post_relatedpost', 'related_id');
     }
     $newIds = $object->getRelatedProductIds();
     if (is_array($newIds)) {
         $oldIds = $this->lookupRelatedProductIds($object->getId());
         $this->_updateLinks($object, $newIds, $oldIds, 'magefan_blog_post_relatedproduct', 'related_id');
     }
     return parent::_afterSave($object);
 }
开发者ID:samitrimal,项目名称:Blog-Extension-for-Magento-2,代码行数:31,代码来源:Post.php


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