Example #1
0
 /**
  * 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;
 }
Example #2
0
 /**
  * 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;
 }
 /**
  * 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;
 }
Example #4
0
 /**
  * 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;
 }