Example #1
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;
 }
 /**
  * Updates information in CRM about catalog.$assignedUserName
  * @param CmlCatalog $cmlCatalog
  */
 public function save($cmlCatalog)
 {
     $catalogName = $cmlCatalog->getName();
     $reference = $this->getReference($catalogName);
     if ($reference != null) {
         $this->updateCatalog($reference, $cmlCatalog);
     } else {
         $this->createCatalog($cmlCatalog);
     }
 }