From db784de3692005c47740283e749c8cdfe243d08d Mon Sep 17 00:00:00 2001 From: azgalot Date: Thu, 15 Jun 2017 11:31:02 +0300 Subject: [PATCH] add url product (#21) --- MoySkladICMLParser.php | 24 +++++++++++++++++------- 1 file changed, 17 insertions(+), 7 deletions(-) diff --git a/MoySkladICMLParser.php b/MoySkladICMLParser.php index 5b571f2..a927f59 100644 --- a/MoySkladICMLParser.php +++ b/MoySkladICMLParser.php @@ -298,26 +298,32 @@ class MoySkladICMLParser 'price' => isset($assortiment['salePrices'][0]['value']) ? (((float)$assortiment['salePrices'][0]['value']) / 100) : (((float)$assortiment['product']['salePrices'][0]['value']) / 100), - 'purchasePrice' => isset($assortiment['buyPrice']['value']) ? (((float)$assortiment['buyPrice']['value']) / 100) : - (((float)$assortiment['product']['buyPrice']['value']) / 100), - + ( + isset($assortiment['product']['buyPrice']['value']) ? + (((float)$assortiment['product']['buyPrice']['value']) / 100) : + 0 + ), 'weight' => isset($assortiment['weight']) ? $assortiment['weight'] : $assortiment['product']['weight'], - 'code' => isset($assortiment['code']) ? (string) $assortiment['code'] : '', - 'xmlId' => !empty($assortiment['product']['externalCode']) ? ($assortiment['product']['externalCode'] . '#' . $assortiment['externalCode']) : $assortiment['externalCode'], - 'image' => array( 'content' => isset($image) ? $image : '', 'name' => isset($assortiment['product']['image']['filename']) ? $assortiment['product']['image']['filename'] : '', 'id' => $assortiment['id'], ), + 'url' => !empty($assortiment['product']['meta']['uuidHref']) ? + $assortiment['product']['meta']['uuidHref'] : + ( + !empty($assortiment['meta']['uuidHref']) ? + $assortiment['meta']['uuidHref'] : + '' + ) ); if (isset($assortiment['uom']) && isset($assortiment['uom']['code'])) { @@ -426,7 +432,11 @@ class MoySkladICMLParser $this->icmlAdd($offerXml, 'purchasePrice', number_format($product['purchasePrice'], 2, '.', '')); $this->icmlAdd($offerXml, 'name', htmlspecialchars($product['name'])); $this->icmlAdd($offerXml, 'productName', htmlspecialchars($product['productName'])); - $this->icmlAdd($offerXml, 'vatRate',$product['effectiveVat']); + $this->icmlAdd($offerXml, 'vatRate', $product['effectiveVat']); + + if (!empty($product['url'])) { + $this->icmlAdd($offerXml, 'url', htmlspecialchars($product['url'])); + } if ($product['unit'] != '') { $unitXml = $offerXml->addChild('unit');