当前位置: 首页>>代码示例>>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;未经允许,请勿转载。