示例#1
0
 /**
  * Load Item model by product
  *
  * @param Mage_GoogleShopping_Model_Item $model
  * @return Mage_GoogleShopping_Model_Mysql4_Item
  */
 public function loadByProduct($model)
 {
     if (!$model->getProduct() instanceof Varien_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 : array();
         $model->addData($data);
     }
     return $this;
 }
示例#2
0
 /**
  * Retrieve item query for Google Content
  *
  * @param Mage_GoogleShopping_Model_Item $item
  * @return Varien_Gdata_Gshopping_ItemQuery
  */
 protected function _buildItemQuery($item)
 {
     $storeId = $item->getStoreId();
     $service = $this->getService($storeId);
     $countryInfo = $this->getConfig()->getTargetCountryInfo($storeId);
     $itemId = Mage::helper('Mage_GoogleShopping_Helper_Data')->buildContentProductId($item->getProductId(), $item->getStoreId());
     $query = $service->newItemQuery()->setId($itemId)->setTargetCountry($this->getConfig()->getTargetCountry($storeId))->setLanguage($countryInfo['language']);
     return $query;
 }