當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。