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


PHP AbstractModel::getStores方法代码示例

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


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

示例1: _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('cms_block_store');
     $insert = array_diff($newStores, $oldStores);
     $delete = array_diff($oldStores, $newStores);
     if ($delete) {
         $where = ['block_id = ?' => (int) $object->getId(), 'store_id IN (?)' => $delete];
         $this->_getWriteAdapter()->delete($table, $where);
     }
     if ($insert) {
         $data = [];
         foreach ($insert as $storeId) {
             $data[] = ['block_id' => (int) $object->getId(), 'store_id' => (int) $storeId];
         }
         $this->_getWriteAdapter()->insertMultiple($table, $data);
     }
     return parent::_afterSave($object);
 }
开发者ID:shabbirvividads,项目名称:magento2,代码行数:26,代码来源:Block.php

示例2: _afterSave

 /**
  * Perform actions after object save
  *
  * @param \Magento\Framework\Model\AbstractModel $object
  * @return $this
  */
 protected function _afterSave(AbstractModel $object)
 {
     $adapter = $this->_getWriteAdapter();
     /**
      * save detail
      */
     $detail = ['title' => $object->getTitle(), 'detail' => $object->getDetail(), 'nickname' => $object->getNickname()];
     $select = $adapter->select()->from($this->_reviewDetailTable, 'detail_id')->where('review_id = :review_id');
     $detailId = $adapter->fetchOne($select, [':review_id' => $object->getId()]);
     if ($detailId) {
         $condition = ["detail_id = ?" => $detailId];
         $adapter->update($this->_reviewDetailTable, $detail, $condition);
     } else {
         $detail['store_id'] = $object->getStoreId();
         $detail['customer_id'] = $object->getCustomerId();
         $detail['review_id'] = $object->getId();
         $adapter->insert($this->_reviewDetailTable, $detail);
     }
     /**
      * save stores
      */
     $stores = $object->getStores();
     if (!empty($stores)) {
         $condition = ['review_id = ?' => $object->getId()];
         $adapter->delete($this->_reviewStoreTable, $condition);
         $insertedStoreIds = [];
         foreach ($stores as $storeId) {
             if (in_array($storeId, $insertedStoreIds)) {
                 continue;
             }
             $insertedStoreIds[] = $storeId;
             $storeInsert = ['store_id' => $storeId, 'review_id' => $object->getId()];
             $adapter->insert($this->_reviewStoreTable, $storeInsert);
         }
     }
     // reaggregate ratings, that depend on this review
     $this->_aggregateRatings($this->_loadVotedRatingIds($object->getId()), $object->getEntityPkValue());
     return $this;
 }
开发者ID:shabbirvividads,项目名称:magento2,代码行数:45,代码来源:Review.php

示例3: processRatingStores

 /**
  * @param \Magento\Framework\Model\AbstractModel $object
  * @return $this
  */
 protected function processRatingStores(\Magento\Framework\Model\AbstractModel $object)
 {
     $adapter = $this->_getWriteAdapter();
     $ratingId = (int) $object->getId();
     $table = $this->getTable('rating_store');
     $select = $adapter->select()->from($table, ['store_id'])->where('rating_id = :rating_id');
     $old = $adapter->fetchCol($select, [':rating_id' => $ratingId]);
     $new = $object->getStores();
     $this->deleteRatingData($ratingId, $table, array_diff_assoc($old, $new));
     $insert = [];
     foreach (array_keys(array_diff_assoc($new, $old)) as $storeId) {
         $insert[] = ['rating_id' => $ratingId, 'store_id' => (int) $storeId];
     }
     $this->insertRatingData($table, $insert);
     return $this;
 }
开发者ID:nja78,项目名称:magento2,代码行数:20,代码来源:Rating.php

示例4: _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

示例5: _afterSave

 /**
  * Assign page to store views
  *
  * @param \Magento\Framework\Model\AbstractModel $object
  * @return $this
  */
 protected function _afterSave(\Magento\Framework\Model\AbstractModel $object)
 {
     /** @var \AddictedToMagento\DynamicForms\Model\Form $object */
     $oldStores = $this->lookupStoreIds($object->getId());
     $newStores = (array) $object->getStores();
     if (empty($newStores)) {
         $newStores = (array) $object->getStoreId();
     }
     $table = $this->getTable(self::STORE_TABLE_NAME);
     $insert = array_diff($newStores, $oldStores);
     $delete = array_diff($oldStores, $newStores);
     if ($delete) {
         $where = ['form_id = ?' => (int) $object->getId(), 'store_id IN (?)' => $delete];
         $this->getConnection()->delete($table, $where);
     }
     if ($insert) {
         $data = [];
         foreach ($insert as $storeId) {
             $data[] = ['form_id' => (int) $object->getId(), 'store_id' => (int) $storeId];
         }
         $this->getConnection()->insertMultiple($table, $data);
     }
     return parent::_afterSave($object);
 }
开发者ID:AddictedToMagento,项目名称:dynamic-forms,代码行数:30,代码来源:Form.php

示例6: checkUrlExits

 public function checkUrlExits(\Magento\Framework\Model\AbstractModel $object)
 {
     $stores = $object->getStores();
     $connection = $this->getConnection();
     $select = $connection->select()->from($this->getTable('ves_brand'), 'brand_id')->where('url_key = ?', $object->getUrlKey())->where('brand_id != ?', $object->getId());
     $brandIds = $connection->fetchCol($select);
     if (count($brandIds) > 0 && is_array($stores)) {
         if (in_array('0', $stores)) {
             throw new \Magento\Framework\Exception\LocalizedException(__('URL key for specified store already exists.'));
         }
         $stores[] = '0';
         $select = $connection->select()->from($this->getTable('ves_brand_store'), 'brand_id')->where('brand_id IN (?)', $brandIds)->where('store_id IN (?)', $stores);
         $result = $connection->fetchCol($select);
         if (count($result) > 0) {
             throw new \Magento\Framework\Exception\LocalizedException(__('URL key for specified store already exists.'));
         }
     }
     return $this;
 }
开发者ID:vasuscoin,项目名称:brand,代码行数:19,代码来源:Brand.php


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