예제 #1
0
 /**
  * Save products and services from $cmlCatalog and add them to Catalog with reference
  * $catalogReference.
  * @param String $catalogReference
  * @param CmlCatalog $cmlCatalog
  */
 private function updateCatalogInventories($catalogReference, $cmlCatalog)
 {
     $products = $cmlCatalog->getProducts();
     foreach ($products as $cmlProduct) {
         $inventoryReference = $this->productsController->save($cmlProduct);
         $this->addInventory($catalogReference, $inventoryReference, $cmlProduct);
     }
     $services = $cmlCatalog->getServices();
     foreach ($services as $cmlService) {
         $inventoryReference = $this->servicesController->save($cmlService);
         $this->addInventory($catalogReference, $inventoryReference, $cmlService);
     }
 }
예제 #2
0
 /**
  * Add to products in $catalog prices, count and currency from $package.
  * Return updated $catalog.
  * @param CmlCatalog $catalog
  * @param CmlCatalog $package
  * @return CmlCatalog
  */
 private function joinImportWithOfferProducts($catalog, $package)
 {
     $catalogProducts = $catalog->getProducts();
     foreach ($catalogProducts as $number => $catalogProduct) {
         //key need to change product in array
         foreach ($package->getProducts() as $packageProduct) {
             //in package all inventories as products
             if ($catalogProduct->compare($packageProduct)) {
                 /* Add price, currency and count of product - and reinitilizate array of products */
                 $catalogProduct->mergeImportWithOffer($packageProduct);
                 $catalogProducts[$number] = $catalogProduct;
                 break;
                 //no need search more products
             }
         }
     }
     /* Reinit catalog products */
     $catalog->setProducts($catalogProducts);
     return $catalog;
 }