예제 #1
0
 /**
  * @param ImportProduct $productToUpdate
  * @param bool $synchronizeImages
  * @throws Exception
  */
 private function updateFromSource($productToUpdate, $synchronizeImages = true)
 {
     $localProduct = $this->modelCatalogProduct->getProduct($productToUpdate->getLocalProductId());
     $thumbnail = null;
     $images = array();
     $imageDescription = $localProduct['image_description'] ? $localProduct['image_description'] : $productToUpdate->getDescription();
     if ($synchronizeImages) {
         $this->getImages($productToUpdate, $images, $thumbnail);
         $imageDescription = $this->updateDescriptionImages($productToUpdate->getId(), $imageDescription);
     }
     /// Preparing name, korean name and description
     //        $product_description = array();
     //        foreach ($this->load->model('localisation/language')->getLanguages() as $language) {
     //            $product_description[$language['language_id']] = array(
     //                'name' => $productToUpdate->getName(),
     //                'description' => null
     //            );
     //        }
     /// Copying product options in order to preserve ones
     $localProductOptions = $this->modelCatalogProduct->getProductOptions($productToUpdate->getLocalProductId());
     /// Copying product categories in order to preserve ones
     $localProductCategories = $this->modelCatalogProduct->getProductCategories($productToUpdate->getLocalProductId());
     $this->modelCatalogProduct->editProduct($productToUpdate->getLocalProductId(), array('date_available' => $localProduct['date_available'], 'image_description' => $imageDescription, 'height' => null, 'image' => $thumbnail, 'length' => null, 'length_class_id' => 1, 'location' => null, 'manufacturer_id' => $productToUpdate->getSourceSite()->getDefaultManufacturer()->getId(), 'meta_keywords' => null, 'meta_description' => null, 'minimum' => $productToUpdate->getMinimalAmount(), 'model' => $localProduct['model'], 'points' => null, 'price' => $productToUpdate->getSourcePrice()->getPrice() * $productToUpdate->getSourceSite()->getRegularCustomerPriceRate(), 'product_category' => $localProductCategories, 'product_description' => $this->modelCatalogProduct->getProductDescriptions($productToUpdate->getLocalProductId()), 'product_image' => $images, 'product_option' => $localProductOptions, 'product_special' => $this->getSpecialPrices($productToUpdate), 'product_store' => $productToUpdate->getSourceSite()->getStores(), 'product_tag' => null, 'seo_title' => null, 'seo_h1' => null, 'shipping' => 1, 'sku' => null, 'sort_order' => null, 'stock_status_id' => 8, 'status' => $localProduct['status'], 'subtract' => null, 'supplier_id' => $productToUpdate->getSourceSite()->getDefaultSupplier()->getId(), 'tax_class' => null, 'upc' => null, 'user_id' => 0, 'weight' => $localProduct['weight'], 'weight_class_id' => $localProduct['weight_class_id'], 'width' => null, 'koreanName' => $productToUpdate->getName(), 'supplierUrl' => $productToUpdate->getSourceUrl()));
 }