/** * 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); } }
/** * 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; }