From fa207afd1549cc891a5c644b05ea2f3689b79318 Mon Sep 17 00:00:00 2001 From: gorokh Date: Tue, 7 Apr 2020 13:55:59 +0300 Subject: [PATCH 1/3] issues #92 --- intaro.retailcrm/classes/general/icml/RetailCrmICML.php | 2 ++ 1 file changed, 2 insertions(+) diff --git a/intaro.retailcrm/classes/general/icml/RetailCrmICML.php b/intaro.retailcrm/classes/general/icml/RetailCrmICML.php index f8ec28d4..6c595b15 100644 --- a/intaro.retailcrm/classes/general/icml/RetailCrmICML.php +++ b/intaro.retailcrm/classes/general/icml/RetailCrmICML.php @@ -623,6 +623,8 @@ class RetailCrmICML $offer .= "" . $this->PrepareValue($arOffer['PRICE']) . "\n"; if ($arOffer['PURCHASE_PRICE'] && $this->loadPurchasePrice) { $offer .= "" . $this->PrepareValue($arOffer['PURCHASE_PRICE']) . "\n"; + } else { + $offer .= "0\n"; } foreach ($categories as $category) { $offer .= "" . $category['ID'] . "\n"; From 30555f8146b7fa53013cdc624692c08535b2b637 Mon Sep 17 00:00:00 2001 From: gorokh Date: Wed, 8 Apr 2020 17:27:05 +0300 Subject: [PATCH 2/3] add options purchasePrice --- .../classes/general/icml/RetailCrmICML.php | 5 ++- intaro.retailcrm/options.php | 40 +++++++++++++++++++ 2 files changed, 44 insertions(+), 1 deletion(-) diff --git a/intaro.retailcrm/classes/general/icml/RetailCrmICML.php b/intaro.retailcrm/classes/general/icml/RetailCrmICML.php index 6c595b15..9fd0ee2f 100644 --- a/intaro.retailcrm/classes/general/icml/RetailCrmICML.php +++ b/intaro.retailcrm/classes/general/icml/RetailCrmICML.php @@ -29,6 +29,7 @@ class RetailCrmICML protected $mainSection = 1000000; protected $pageSize = 500; protected $protocol; + protected $purchasePriceNull; protected $isLogged = false; protected $logFile = '/bitrix/catalog_export/i_crm_load_log.txt'; @@ -37,6 +38,7 @@ class RetailCrmICML protected $MODULE_ID = 'intaro.retailcrm'; protected $CRM_CATALOG_BASE_PRICE = 'catalog_base_price'; protected $PROTOCOL_OPTION = 'protocol'; + protected $CRM_PURCHASE_PRICE_NULL = 'purchasePrice_null'; protected $measurement = array ( 'mm' => 1, // 1 mm = 1 mm @@ -76,6 +78,7 @@ class RetailCrmICML $this->encodingDefault = $defaultSite["CHARSET"]; $this->protocol = COption::GetOptionString($this->MODULE_ID, $this->PROTOCOL_OPTION); + $this->purchasePriceNull = COption::GetOptionString($this->MODULE_ID, $this->CRM_PURCHASE_PRICE_NULL); $this->PrepareSettings(); @@ -623,7 +626,7 @@ class RetailCrmICML $offer .= "" . $this->PrepareValue($arOffer['PRICE']) . "\n"; if ($arOffer['PURCHASE_PRICE'] && $this->loadPurchasePrice) { $offer .= "" . $this->PrepareValue($arOffer['PURCHASE_PRICE']) . "\n"; - } else { + } elseif ("Y" == $this->purchasePriceNull) { $offer .= "0\n"; } foreach ($categories as $category) { diff --git a/intaro.retailcrm/options.php b/intaro.retailcrm/options.php index fb995d66..b3cc6a0e 100644 --- a/intaro.retailcrm/options.php +++ b/intaro.retailcrm/options.php @@ -46,6 +46,7 @@ $CRM_DIMENSIONS = 'order_dimensions'; $PROTOCOL = 'protocol'; $CRM_DISCOUNT_ROUND = 'discount_round'; +$CRM_PURCHASE_PRICE_NULL = 'purchasePrice_null'; if(!CModule::IncludeModule('intaro.retailcrm') || !CModule::IncludeModule('sale') || !CModule::IncludeModule('iblock') || !CModule::IncludeModule('catalog')) return; @@ -451,6 +452,15 @@ if (isset($_POST['Update']) && ($_POST['Update'] == 'Y')) { UnRegisterModuleDependences("main", "OnBeforeProlog", $mid, "RetailCrmDc", "add"); } + //purchasePrice_null + if (htmlspecialchars(trim($_POST['purchasePrice_null'])) == 'Y') { + $purchasePrice_null = 'Y'; + RegisterModuleDependences("main", "OnBeforeProlog", $mid, "RetailCrmPricePrchase", "add"); + } else { + $purchasePrice_null = 'N'; + UnRegisterModuleDependences("main", "OnBeforeProlog", $mid, "RetailCrmPricePrchase", "add"); + } + //version $version = COption::GetOptionString($mid, $CRM_API_VERSION); @@ -526,6 +536,7 @@ if (isset($_POST['Update']) && ($_POST['Update'] == 'Y')) { COption::SetOptionString($mid, $CRM_DIMENSIONS, $orderDimensions); COption::SetOptionString($mid, $CRM_DISCOUNT_ROUND, $discount_round); + COption::SetOptionString($mid, $CRM_PURCHASE_PRICE_NULL, $purchasePrice_null); $request = \Bitrix\Main\Application::getInstance()->getContext()->getRequest(); @@ -634,6 +645,7 @@ if (isset($_POST['Update']) && ($_POST['Update'] == 'Y')) { $optionUaKeys = unserialize(COption::GetOptionString($mid, $CRM_UA_KEYS)); $optionDiscRound = COption::GetOptionString($mid, $CRM_DISCOUNT_ROUND, 0); + $optionPricePrchaseNull = COption::GetOptionString($mid, $CRM_PURCHASE_PRICE_NULL, 0); $version = COption::GetOptionString($mid, $CRM_API_VERSION, 0); @@ -752,6 +764,17 @@ if (isset($_POST['Update']) && ($_POST['Update'] == 'Y')) { return true; }); + + $('.r-purchaseprice-button label').change(function() { + if($(this).find('input').is(':checked') === true) { + $('tr.r-purchaseprice').show('slow'); + } else if($(this).find('input').is(':checked') === false) { + $('tr.r-purchaseprice').hide('slow'); + } + + return true; + }); + }); $('input[name="update-delivery-services"]').live('click', function() { @@ -1303,6 +1326,23 @@ if (isset($_POST['Update']) && ($_POST['Update'] == 'Y')) { + + + + + + + + + > + + + + + From 735b0f977d20ab8394d828e9701050fbe4363827 Mon Sep 17 00:00:00 2001 From: gorokh Date: Wed, 15 Apr 2020 16:01:21 +0300 Subject: [PATCH 3/3] logic fix --- .../classes/general/icml/RetailCrmICML.php | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/intaro.retailcrm/classes/general/icml/RetailCrmICML.php b/intaro.retailcrm/classes/general/icml/RetailCrmICML.php index 9fd0ee2f..740aa32f 100644 --- a/intaro.retailcrm/classes/general/icml/RetailCrmICML.php +++ b/intaro.retailcrm/classes/general/icml/RetailCrmICML.php @@ -624,11 +624,15 @@ class RetailCrmICML $offer .= "" . $this->protocol . $this->serverName . $this->PrepareValue($arOffer['DETAIL_PAGE_URL']) . "\n"; $offer .= "" . $this->PrepareValue($arOffer['PRICE']) . "\n"; - if ($arOffer['PURCHASE_PRICE'] && $this->loadPurchasePrice) { - $offer .= "" . $this->PrepareValue($arOffer['PURCHASE_PRICE']) . "\n"; - } elseif ("Y" == $this->purchasePriceNull) { - $offer .= "0\n"; + + if ($this->loadPurchasePrice) { + if ($arOffer['PURCHASE_PRICE']) { + $offer .= "" . $this->PrepareValue($arOffer['PURCHASE_PRICE']) . "\n"; + } elseif ("Y" == $this->purchasePriceNull) { + $offer .= "0\n"; + } } + foreach ($categories as $category) { $offer .= "" . $category['ID'] . "\n"; }