public function map($okProduct) { $bfProduct = BfObjectFactory::getInstance("BfProduct", $this->bfVersion); $bfProductFieldsValidators = BfObjectFactory::getValidators("BfProduct", $this->bfVersion); $bfObjectFiller = new BfObjectFiller($bfProduct, $bfProductFieldsValidators, $this->logger); $productAvailability = new OkProductAvailability(); $productAvailability->setLeadtimeToShip($okProduct->leadtime_to_ship); $productAvailability->setQuantity($okProduct->quantity); $bfObjectFiller->putIntoIfValid("MasterProductId", BfDataFormatter::prefixKey($okProduct->sku, $this->idPrefix)); $bfObjectFiller->putIntoIfValid("InternalName", $okProduct->products_products_model); $bfObjectFiller->putIntoIfValid("ProductName", BfDataFormatter::formatName($okProduct->products_description_products_name)); $bfObjectFiller->putIntoIfValid("SalesPitch", $okProduct->products_description_products_informations); if ($okProduct->products_description_products_description == "") { $longDescription = _("No description available"); } else { $longDescription = $okProduct->products_description_products_description; } $bfObjectFiller->putIntoIfValid("LongDescription", $longDescription); $bfObjectFiller->putIntoIfValid("DeliveryInfo", $productAvailability->getStatus()); $discoDate = $productAvailability->getDiscoDate(); if ($discoDate != "") { $bfObjectFiller->putIntoIfValid("DiscoDate", $discoDate); } $bfObjectFiller->putIntoIfValid("PlpLabel", $okProduct->products_products_model); $bfObjectFiller->putIntoIfValid("PdpLabel", $okProduct->products_products_model); $bfObjectFiller->putIntoIfValid("ProductWeight", $okProduct->products_products_weight); $bfObjectFiller->putIntoIfValid("Returnable", "Y"); $bfObjectFiller->putIntoIfValid("Taxable", "Y"); $bfObjectFiller->putIntoIfValid("ChargeShipping", "Y"); $bfObjectFiller->putIntoIfValid("ManufacturerId", BfDataFormatter::prefixKey($okProduct->products_manufacturers_id, $this->idPrefix)); $bfObjectFiller->putIntoIfValid("ProductPrice->ListPrice->Price", BfDataFormatter::formatToDecimal3($okProduct->regular_price)); $bfObjectFiller->putIntoIfValid("ProductPrice->ListPrice->Currency", "EUR"); $bfObjectFiller->putIntoIfValid("ProductPrice->SalesPrice->Price", BfDataFormatter::formatToDecimal3($okProduct->final_price)); $bfObjectFiller->putIntoIfValid("ProductPrice->SalesPrice->Currency", "EUR"); // On prend seulement le premier id de catégorie pour l'instant $okCategoryTree = explode(",", $okProduct->categories_categories_id); $bfObjectFiller->putIntoIfValid("ProductCategoryMember->Category[0]->CategoryId", $okCategoryTree[0]); $bfObjectFiller->putIntoIfValid("ProductCategoryMember->Category[1]->CategoryId", $this->taxCategory); $bfObjectFiller->putIntoIfValid("ProductCategoryMember->Category[2]->CategoryId", $this->viewAllowCategory); $viewAllowTruDate = $productAvailability->getViewAllowThruDate(); if ($viewAllowTruDate != "") { $bfObjectFiller->putIntoIfValid("ProductCategoryMember->Category[2]->ThruDate", $viewAllowTruDate); } $imageUrl = new ImageUrl($okProduct->products_products_image); $bfObjectFiller->putIntoIfValid("ProductImage->PlpSmallImage->Url", $imageUrl->getSquareUrl()); $bfObjectFiller->putIntoIfValid("ProductImage->PdpThumbnailImage->Url", $imageUrl->getThumbnailUrl()); $bfObjectFiller->putIntoIfValid("ProductImage->PdpLargeImage->Url", $imageUrl->getSquareUrl()); $bfObjectFiller->putIntoIfValid("ProductImage->PdpDetailImage->Url", $imageUrl->getHiResUrl()); $bfObjectFiller->putIntoIfValid("ProductGoodIdentification->Sku", $okProduct->sku); $bfObjectFiller->putIntoIfValid("ProductGoodIdentification->Isbn", $okProduct->products_help_ean); $bfObjectFiller->putIntoIfValid("ProductGoodIdentification->ManuId", $okProduct->products_help_marque_ref); $bfObjectFiller->putIntoIfValid("ProductInventory->BigfishInventoryTotal", $okProduct->gros_products_info_gros_products_stock); $bfObjectFiller->putIntoIfValid("ProductInventory->BigfishInventoryWarehouse", $okProduct->gros_products_info_gros_products_stock); $bfProductValidator = new BfProductValidator($this->logger); if (false == $bfProductValidator->isComplete($bfProduct)) { throw new XmlItemMapperException(sprintf("Incomplete product <%s>", $okProduct->sku)); } return $bfProduct; }
public function map($okProductUpdate) { $bfProductUpdate = BfObjectFactory::getInstance("BfProductUpdate", $this->bfVersion); $bfProductUpdateFieldsValidators = BfObjectFactory::getValidators("BfProductUpdate", $this->bfVersion); $bfObjectFiller = new BfObjectFiller($bfProductUpdate, $bfProductUpdateFieldsValidators, $this->logger); $productAvailability = new OkProductAvailability(); $productAvailability->setLeadtimeToShip($okProductUpdate->leadtime_to_ship); $productAvailability->setQuantity($okProductUpdate->quantity); $bfObjectFiller->putIntoIfValid("MasterProductId", BfDataFormatter::prefixKey($okProductUpdate->sku, $this->idPrefix)); if ($okProductUpdate->products_description_products_description == "") { $longDescription = _("No description available"); } else { $longDescription = $okProductUpdate->products_description_products_description; } $bfObjectFiller->putIntoIfValid("LongDescription", $longDescription); $bfObjectFiller->putIntoIfValid("DeliveryInfo", $productAvailability->getStatus()); $discoDate = $productAvailability->getDiscoDate(); if ($discoDate != "") { $bfObjectFiller->putIntoIfValid("DiscoDate", $discoDate); } $bfObjectFiller->putIntoIfValid("ProductPrice->ListPrice->Price", BfDataFormatter::formatToDecimal3($okProductUpdate->regular_price)); $bfObjectFiller->putIntoIfValid("ProductPrice->ListPrice->Currency", "EUR"); $bfObjectFiller->putIntoIfValid("ProductPrice->SalesPrice->Price", BfDataFormatter::formatToDecimal3($okProductUpdate->final_price)); $bfObjectFiller->putIntoIfValid("ProductPrice->SalesPrice->Currency", "EUR"); // On prend seulement le premier id de catégorie pour l'instant $okCategoryTree = explode(",", $okProductUpdate->categories_categories_id); $bfObjectFiller->putIntoIfValid("ProductCategoryMember->Category[0]->CategoryId", $okCategoryTree[0]); $bfObjectFiller->putIntoIfValid("ProductCategoryMember->Category[1]->CategoryId", $this->taxCategory); $bfObjectFiller->putIntoIfValid("ProductCategoryMember->Category[2]->CategoryId", $this->viewAllowCategory); $viewAllowTruDate = $productAvailability->getViewAllowThruDate(); if ($viewAllowTruDate != "") { $bfObjectFiller->putIntoIfValid("ProductCategoryMember->Category[2]->ThruDate", $viewAllowTruDate); } $bfObjectFiller->putIntoIfValid("ProductInventory->BigfishInventoryTotal", $okProductUpdate->quantity); $bfObjectFiller->putIntoIfValid("ProductInventory->BigfishInventoryWarehouse", $okProductUpdate->quantity); $bfProductValidator = new BfProductValidator($this->logger); if (false == $bfProductValidator->isComplete($bfProductUpdate)) { throw new XmlItemMapperException(sprintf("Incomplete product update <%s>", $okProductUpdate->sku)); } return $bfProductUpdate; }