Example #1
0
 /**
  * Load Item model by product
  *
  * @param \Magento\GoogleShopping\Model\Item $model
  * @return $this
  */
 public function loadByProduct($model)
 {
     if (!$model->getProduct() instanceof \Magento\Framework\Object) {
         return $this;
     }
     $product = $model->getProduct();
     $productId = $product->getId();
     $storeId = $model->getStoreId() ? $model->getStoreId() : $product->getStoreId();
     $read = $this->_getReadAdapter();
     $select = $read->select();
     if ($productId !== null) {
         $select->from($this->getMainTable())->where("product_id = ?", $productId)->where('store_id = ?', (int) $storeId);
         $data = $read->fetchRow($select);
         $data = is_array($data) ? $data : [];
         $model->addData($data);
     }
     return $this;
 }
Example #2
0
 /**
  * Retrieve item query for Google Content
  *
  * @param \Magento\GoogleShopping\Model\Item $item
  * @return \Magento\Framework\Gdata\Gshopping\ItemQuery
  */
 protected function _buildItemQuery($item)
 {
     $storeId = $item->getStoreId();
     $service = $this->getService($storeId);
     $countryInfo = $this->getConfig()->getTargetCountryInfo($storeId);
     $itemId = $this->_gsData->buildContentProductId($item->getProductId(), $item->getStoreId());
     $query = $service->newItemQuery()->setId($itemId)->setTargetCountry($this->getConfig()->getTargetCountry($storeId))->setLanguage($countryInfo['language']);
     return $query;
 }