Ejemplo n.º 1
0
 /**
  * @inheritdoc
  */
 public function initContent()
 {
     $context = $this->module->getContext();
     $collection = new NostoExportProductCollection();
     foreach ($this->getProductIds() as $id_product) {
         $product = new Product($id_product, true, $context->language->id, $context->shop->id);
         if (!Validate::isLoadedObject($product)) {
             continue;
         }
         $nosto_product = new NostoTaggingProduct();
         $nosto_product->loadData($context, $product);
         $validator = new NostoValidator($nosto_product);
         if ($validator->validate()) {
             $collection[] = $nosto_product;
         }
         $product = null;
     }
     $this->encryptOutput($collection);
 }
 /**
  * Loads a Nosto product model for given PS product ID, language ID and shop ID.
  *
  * @param int $id_product the PS product ID.
  * @param int $id_lang the language ID.
  * @param int $id_shop the shop ID.
  * @return NostoTaggingProduct|null the product or null if could not be loaded.
  */
 protected function loadNostoProduct($id_product, $id_lang, $id_shop)
 {
     $product = new Product($id_product, false, $id_lang, $id_shop);
     if (!Validate::isLoadedObject($product)) {
         return null;
     }
     if (isset($product->visibility) && $product->visibility === 'none') {
         return null;
     }
     $this->makeContextSnapshot();
     $nosto_product = new NostoTaggingProduct();
     $nosto_product->loadData($this->makeContext($id_lang, $id_shop), $product);
     $this->restoreContextSnapshot();
     $validator = new NostoValidator($nosto_product);
     if (!$validator->validate()) {
         return null;
     }
     return $nosto_product;
 }