當前位置: 首頁>>代碼示例>>PHP>>正文


PHP AbstractModel::getStoreIds方法代碼示例

本文整理匯總了PHP中Magento\Framework\Model\AbstractModel::getStoreIds方法的典型用法代碼示例。如果您正苦於以下問題:PHP AbstractModel::getStoreIds方法的具體用法?PHP AbstractModel::getStoreIds怎麽用?PHP AbstractModel::getStoreIds使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在Magento\Framework\Model\AbstractModel的用法示例。


在下文中一共展示了AbstractModel::getStoreIds方法的4個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的PHP代碼示例。

示例1: aroundSave

 /**
  * @param \Magento\Store\Model\ResourceModel\Group $object
  * @param callable $proceed
  * @param AbstractModel $group
  * @return \Magento\Store\Model\ResourceModel\Group
  * @SuppressWarnings(PHPMD.UnusedFormalParameter)
  */
 public function aroundSave(\Magento\Store\Model\ResourceModel\Group $object, \Closure $proceed, AbstractModel $group)
 {
     $originGroup = $group;
     $result = $proceed($originGroup);
     if (!$group->isObjectNew() && ($group->dataHasChangedFor('website_id') || $group->dataHasChangedFor('root_category_id'))) {
         $this->storeManager->reinitStores();
         foreach ($group->getStoreIds() as $storeId) {
             $this->urlPersist->deleteByData([UrlRewrite::STORE_ID => $storeId]);
         }
         $this->urlPersist->replace($this->generateCategoryUrls($group->getRootCategoryId(), $group->getStoreIds()));
         $this->urlPersist->replace($this->generateProductUrls($group->getWebsiteId(), $group->getOrigData('website_id')));
     }
     return $result;
 }
開發者ID:kidaa30,項目名稱:magento2-platformsh,代碼行數:21,代碼來源:Group.php

示例2: saveStoreRelation

 /**
  * Saves relation between thesaurus and store
  *
  * @param \Magento\Framework\Model\AbstractModel $object Thesaurus to save
  *
  * @return void
  */
 private function saveStoreRelation(\Magento\Framework\Model\AbstractModel $object)
 {
     $storeIds = $object->getStoreIds();
     if (is_array($storeIds) && count($storeIds) > 0) {
         if (in_array(0, $storeIds)) {
             $storeIds = [0];
         }
         $storeLinks = [];
         $deleteCondition = [ThesaurusInterface::THESAURUS_ID . " = ?" => $object->getThesaurusId()];
         foreach ($storeIds as $key => $storeId) {
             $storeLinks[] = [ThesaurusInterface::THESAURUS_ID => (int) $object->getThesaurusId(), ThesaurusInterface::STORE_ID => (int) $storeId];
             $storeIds[$key] = (int) $storeId;
         }
         $deleteCondition[ThesaurusInterface::STORE_ID . " NOT IN (?)"] = array_keys($storeIds);
         $this->getConnection()->delete($this->getTable(ThesaurusInterface::STORE_TABLE_NAME), $deleteCondition);
         $this->getConnection()->insertOnDuplicate($this->getTable(ThesaurusInterface::STORE_TABLE_NAME), $storeLinks, array_keys(current($storeLinks)));
     }
 }
開發者ID:smile-sa,項目名稱:elasticsuite,代碼行數:25,代碼來源:Thesaurus.php

示例3: _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->getStoreIds();
     if (!$newIds) {
         $newIds = [0];
     }
     $this->_updateLinks($object, $newIds, $oldIds, 'magefan_blog_post_store', 'store_id');
     /* Save category & tag links */
     foreach (['category' => 'categories', 'tag' => 'tags'] as $linkType => $dataKey) {
         $newIds = (array) $object->getData($dataKey);
         foreach ($newIds as $key => $id) {
             if (!$id) {
                 // e.g.: zero
                 unset($newIds[$key]);
             }
         }
         if (is_array($newIds)) {
             $lookup = 'lookup' . ucfirst($linkType) . 'Ids';
             $oldIds = $this->{$lookup}($object->getId());
             $this->_updateLinks($object, $newIds, $oldIds, 'magefan_blog_post_' . $linkType, $linkType . '_id');
         }
     }
     /* Save tags links */
     $newIds = (array) $object->getTags();
     foreach ($newIds as $key => $id) {
         if (!$id) {
             // e.g.: zero
             unset($newIds[$key]);
         }
     }
     if (is_array($newIds)) {
         $oldIds = $this->lookupTagIds($object->getId());
         $this->_updateLinks($object, $newIds, $oldIds, 'magefan_blog_post_tag', 'tag_id');
     }
     /* Save related post & product links */
     if ($links = $object->getData('links')) {
         if (is_array($links)) {
             foreach (['post', 'product'] as $linkType) {
                 if (!empty($links[$linkType]) && is_array($links[$linkType])) {
                     $linksData = $links[$linkType];
                     $lookup = 'lookupRelated' . ucfirst($linkType) . 'Ids';
                     $oldIds = $this->{$lookup}($object->getId());
                     $this->_updateLinks($object, array_keys($linksData), $oldIds, 'magefan_blog_post_related' . $linkType, 'related_id', $linksData);
                 }
             }
         }
     }
     return parent::_afterSave($object);
 }
開發者ID:magefan,項目名稱:module-blog,代碼行數:56,代碼來源:Post.php

示例4: _afterSave

 /**
  * Assign category to store views
  *
  * @param \Magento\Framework\Model\AbstractModel $object
  * @return $this
  */
 protected function _afterSave(\Magento\Framework\Model\AbstractModel $object)
 {
     $oldStoreIds = $this->lookupStoreIds($object->getId());
     $newStoreIds = (array) $object->getStoreIds();
     if (!$newStoreIds) {
         $newStoreIds = [0];
     }
     $table = $this->getTable('magefan_blog_category_store');
     $insert = array_diff($newStoreIds, $oldStoreIds);
     $delete = array_diff($oldStoreIds, $newStoreIds);
     if ($delete) {
         $where = ['category_id = ?' => (int) $object->getId(), 'store_id IN (?)' => $delete];
         $this->getConnection()->delete($table, $where);
     }
     if ($insert) {
         $data = [];
         foreach ($insert as $storeId) {
             $data[] = ['category_id' => (int) $object->getId(), 'store_id' => (int) $storeId];
         }
         $this->getConnection()->insertMultiple($table, $data);
     }
     return parent::_afterSave($object);
 }
開發者ID:magefan,項目名稱:module-blog,代碼行數:29,代碼來源:Category.php


注:本文中的Magento\Framework\Model\AbstractModel::getStoreIds方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。