コード例 #1
0
ファイル: Item.php プロジェクト: niranjanssiet/magento2
 /**
  * Prepare grid collection object
  *
  * @return $this
  */
 protected function _prepareCollection()
 {
     $collection = $this->_collectionFactory->create();
     $store = $this->_storeManager->getStore($this->getRequest()->getParam('store'));
     $collection->addStoreFilter($store->getId());
     $this->setCollection($collection);
     parent::_prepareCollection();
     return $this;
 }
コード例 #2
0
ファイル: Product.php プロジェクト: shabbirvividads/magento2
 /**
  * Get array with product ids, which was exported to Google Content
  *
  * @return int[]
  */
 protected function _getGoogleShoppingProductIds()
 {
     $collection = $this->_itemCollectionFactory->create()->addStoreFilter($this->_getStore()->getId())->load();
     $productIds = [];
     foreach ($collection as $item) {
         $productIds[] = $item->getProductId();
     }
     return $productIds;
 }
コード例 #3
0
 /**
  * Return items collection by IDs
  *
  * @param int[]|ItemCollection $items
  * @throws CoreException
  * @return null|ItemCollection
  */
 protected function _getItemsCollection($items)
 {
     $itemsCollection = null;
     if ($items instanceof ItemCollection) {
         $itemsCollection = $items;
     } elseif (is_array($items)) {
         $itemsCollection = $this->_collectionFactory->create()->addFieldToFilter('item_id', $items);
     }
     return $itemsCollection;
 }
コード例 #4
0
ファイル: Observer.php プロジェクト: Atlis/docker-magento2
 /**
  * Get items which are available for update/delete when product is saved
  *
  * @param \Magento\Catalog\Model\Product $product
  * @return \Magento\GoogleShopping\Model\Resource\Item\Collection
  */
 protected function _getItemsCollection($product)
 {
     $items = $this->_collectionFactory->create()->addProductFilterId($product->getId());
     if ($product->getStoreId()) {
         $items->addStoreFilter($product->getStoreId());
     }
     foreach ($items as $item) {
         if (!$this->_scopeConfig->isSetFlag('google/googleshopping/observed', \Magento\Store\Model\ScopeInterface::SCOPE_STORE, $item->getStoreId())) {
             $items->removeItemByKey($item->getId());
         }
     }
     return $items;
 }