Example #1
0
 /**
  * Add to services in $catalog prices, count and currency from $package.
  * Return updated $catalog.
  * @param CmlCatalog $catalog
  * @param CmlCatalog $package
  * @return CmlCatalog
  */
 private function joinImportWithOfferServices($catalog, $package)
 {
     $catalogServices = $catalog->getServices();
     foreach ($catalogServices as $number => $catalogService) {
         //key need to change product in array
         foreach ($package->getProducts() as $packageInventory) {
             //in package all inventories as products
             if ($catalogService->compare($packageInventory)) {
                 /* Add price, currency and count of service - and reinitilizate array of services */
                 $catalogService->mergeImportWithOffer($packageInventory);
                 $catalogServices[$number] = $catalogService;
                 break;
                 //no need search more products
             }
         }
     }
     /* Reinit catalog services */
     $catalog->setServices($catalogServices);
     return $catalog;
 }