From 6443e10330b607e6f96cd45942297c062d8b9d1d Mon Sep 17 00:00:00 2001 From: Sergey Date: Wed, 27 Feb 2019 16:05:35 +0300 Subject: [PATCH 1/4] =?UTF-8?q?v3.2.4=20=D0=94=D0=BE=D0=B1=D0=B0=D0=B2?= =?UTF-8?q?=D0=BB=D0=B5=D0=BD=D0=B0=20=D0=B2=D0=BE=D0=B7=D0=BC=D0=BE=D0=B6?= =?UTF-8?q?=D0=BD=D0=BE=D1=81=D1=82=D1=8C=20=D0=BF=D0=B5=D1=80=D0=B5=D0=B4?= =?UTF-8?q?=D0=B0=D1=87=D0=B8=20=D1=84=D0=BA=D1=86=D0=B8=D0=BE=D0=BD=D0=BD?= =?UTF-8?q?=D1=8B=D1=85=20=D1=86=D0=B5=D0=BD=20=D0=BD=D0=B5=D1=81=D0=BA?= =?UTF-8?q?=D0=BE=D0=BB=D1=8C=D0=BA=D0=B8=D1=85=20=D0=B3=D1=80=D1=83=D0=BF?= =?UTF-8?q?=D0=BF=20=D0=BF=D0=BE=D0=BB=D1=8C=D0=B7=D0=BE=D0=B2=D0=B0=D1=82?= =?UTF-8?q?=D0=B5=D0=BB=D0=B5=D0=B9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- CHANGELOG.md | 3 + VERSION | 2 +- .../controller/extension/module/retailcrm.php | 2 + .../model/extension/retailcrm/prices.php | 70 ++-- .../template/extension/module/retailcrm.tpl | 243 ++++++------ .../template/extension/module/retailcrm.twig | 361 +++++++++--------- tests/admin/ModelRetailcrmPricesAdminTest.php | 41 +- 7 files changed, 394 insertions(+), 328 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index df4aeb7..e9c6bbc 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,3 +1,6 @@ +## v.3.2.4 +* Изменена передача типов цен с учетом групп пользователей на сайте + ## v.3.2.2 * Убрана генерация externalId покупателя при заказе без регистрации на сайте. diff --git a/VERSION b/VERSION index be94e6f..351227f 100644 --- a/VERSION +++ b/VERSION @@ -1 +1 @@ -3.2.2 +3.2.4 diff --git a/src/upload/admin/controller/extension/module/retailcrm.php b/src/upload/admin/controller/extension/module/retailcrm.php index f1725e9..cf7295d 100644 --- a/src/upload/admin/controller/extension/module/retailcrm.php +++ b/src/upload/admin/controller/extension/module/retailcrm.php @@ -119,6 +119,7 @@ class ControllerExtensionModuleRetailcrm extends Controller $this->load->model('setting/setting'); $this->load->model('extension/retailcrm/references'); $this->load->model('localisation/currency'); + $this->load->model('customer/customer_group'); $this->load->language('extension/module/retailcrm'); $this->document->setTitle($this->language->get('heading_title')); $this->document->addStyle('/admin/view/stylesheet/retailcrm.css'); @@ -344,6 +345,7 @@ class ControllerExtensionModuleRetailcrm extends Controller if ($apiVersion != 'v3') { $_data['priceTypes'] = $this->model_extension_retailcrm_references ->getPriceTypes(); + $_data['customerGroups'] = $this->model_customer_customer_group->getCustomerGroups(); } } diff --git a/src/upload/admin/model/extension/retailcrm/prices.php b/src/upload/admin/model/extension/retailcrm/prices.php index 5c6c303..36a95f2 100644 --- a/src/upload/admin/model/extension/retailcrm/prices.php +++ b/src/upload/admin/model/extension/retailcrm/prices.php @@ -9,7 +9,7 @@ class ModelExtensionRetailcrmPrices extends Model /** * Constructor - * + * * @param Registry $registry */ public function __construct($registry) @@ -18,6 +18,7 @@ class ModelExtensionRetailcrmPrices extends Model $this->load->library('retailcrm/retailcrm'); $this->load->model('catalog/option'); $this->load->model('setting/setting'); + $this->load->model('customer/customer_group'); $this->moduleTitle = $this->retailcrm->getModuleTitle(); $this->settings = $this->model_setting_setting->getSetting($this->moduleTitle); @@ -25,9 +26,9 @@ class ModelExtensionRetailcrmPrices extends Model /** * Upload prices to CRM - * + * * @param array $products - * @param \RetailcrmProxy $retailcrmApiClient + * @param RetailcrmProxy $retailcrmApiClient * @return mixed bool | array */ public function uploadPrices($products, $retailcrmApiClient) @@ -44,14 +45,15 @@ class ModelExtensionRetailcrmPrices extends Model $retailcrmApiClient->storePricesUpload($priceUpload); } + return $pricesUpload; } /** * Get prices - * + * * @param array $products - * + * * @return mixed */ protected function getPrices($products, $retailcrmApiClient) @@ -59,9 +61,7 @@ class ModelExtensionRetailcrmPrices extends Model $prices = array(); $site = $this->getSite($retailcrmApiClient); - if (!isset($this->settings[$this->moduleTitle . '_special']) - || $this->settings[$this->moduleTitle . '_apiversion'] == 'v3' - ) { + if ($this->settings[$this->moduleTitle . '_apiversion'] == 'v3') { return false; } @@ -72,12 +72,14 @@ class ModelExtensionRetailcrmPrices extends Model continue; } + $productPrice = array(); + if (is_array($specials) && count($specials)) { $productPrice = $this->getSpecialPrice($specials); + } - if (!$productPrice) { - continue; - } + if (empty($productPrice)) { + continue; } $offers = $this->retailcrm->getOffers($product); @@ -109,17 +111,23 @@ class ModelExtensionRetailcrmPrices extends Model } $offerId = implode('_', $offerId); + $price = array(); + + foreach($productPrice as $k => $v) { + if (isset($this->settings[$this->moduleTitle . '_special_' . $k])) { + $price[] = array( + 'code' => $this->settings[$this->moduleTitle . '_special_' . $k], + 'price' => $v + $optionsValues['price'] + ); + } + } $prices[] = array( 'externalId' => $offerId ? $product['product_id'] . '#' . $offerId : $product['product_id'], 'site' => $site, - 'prices' => array( - array( - 'code' => $this->settings[$this->moduleTitle . '_special'], - 'price' => $productPrice + $optionsValues['price'] - ) - ) + 'prices' => $price ); + } } @@ -128,26 +136,32 @@ class ModelExtensionRetailcrmPrices extends Model /** * Get actual special - * + * * @param array $specials - * - * @return float $productPrice + * + * @return array $productPrice */ private function getSpecialPrice($specials) { $date = date('Y-m-d'); $always = '0000-00-00'; - $productPrice = 0; + $productPrice = array(); foreach ($specials as $special) { if (($special['date_start'] == $always && $special['date_end'] == $always) || ($special['date_start'] <= $date && $special['date_end'] >= $date) ) { - if ((isset($priority) && $priority > $special['priority']) - || !isset($priority) - ) { - $productPrice = $special['price']; - $priority = $special['priority']; + if ((isset($groupId) && $groupId == $special['customer_group_id']) || !isset($groupId)) { + if ((isset($priority) && $priority > $special['priority']) + || !isset($priority) + ) { + $productPrice[$special['customer_group_id']] = $special['price']; + $priority = $special['priority']; + $groupId = $special['customer_group_id']; + } + } else { + $productPrice[$special['customer_group_id']] = $special['price']; + $groupId = $special['customer_group_id']; } } } @@ -157,10 +171,10 @@ class ModelExtensionRetailcrmPrices extends Model /** * Get data option - * + * * @param int $optionId * @param int $optionValueId - * + * * @return array */ private function getOptionData($optionId, $optionValueId) { diff --git a/src/upload/admin/view/template/extension/module/retailcrm.tpl b/src/upload/admin/view/template/extension/module/retailcrm.tpl index 9ff2d27..6804a93 100644 --- a/src/upload/admin/view/template/extension/module/retailcrm.tpl +++ b/src/upload/admin/view/template/extension/module/retailcrm.tpl @@ -5,7 +5,7 @@
- + @@ -73,7 +73,7 @@
- +
@@ -90,7 +90,7 @@
- +
@@ -101,7 +101,7 @@ @@ -122,7 +122,7 @@
- +
@@ -135,19 +135,24 @@
- -
- + + +
+ +
+ +
-
+ +
@@ -189,7 +194,7 @@ @@ -220,7 +225,7 @@ @@ -241,7 +246,7 @@ @@ -256,25 +261,25 @@
-
+
-
+
- +
-
+
@@ -325,13 +330,13 @@
@@ -383,13 +388,13 @@
@@ -448,7 +453,7 @@ @@ -458,10 +463,10 @@
-
-
-
- +
+
+
+
@@ -472,7 +477,7 @@ @@ -482,8 +487,8 @@
-
-
+
+
@@ -526,18 +531,18 @@ - -
-
- -
-
- -
- -
- -
+ +
+
+ +
+
+ +
+ +
+ +
@@ -548,70 +553,70 @@ diff --git a/src/upload/admin/view/template/extension/module/retailcrm.twig b/src/upload/admin/view/template/extension/module/retailcrm.twig index 6b7ba84..6d3eca0 100644 --- a/src/upload/admin/view/template/extension/module/retailcrm.twig +++ b/src/upload/admin/view/template/extension/module/retailcrm.twig @@ -3,33 +3,33 @@
{% if error_warning %} -
- - {{ error_warning }} -
+
+ + {{ error_warning }} +
{% endif %} {% if saved_settings.module_retailcrm_url is defined %} - + {% endif %}
@@ -37,13 +37,13 @@
@@ -79,14 +79,14 @@
- {% for country in countries %} -
- -
- {% endfor %} + {% for country in countries %} +
+ +
+ {% endfor %}
@@ -110,8 +110,8 @@ {% if saved_settings.module_retailcrm_apikey is defined and saved_settings.module_retailcrm_apikey and saved_settings.module_retailcrm_url is defined and saved_settings.module_retailcrm_url %} {% if retailcrm_errors|length %} - {% for retailcrm_error in retailcrm_errors %} -
{{ retailcrm_error }}
+ {% for retailcrm_error in retailcrm_errors %} +
{{ retailcrm_error }}
{% endfor %} {% else %}
@@ -131,23 +131,28 @@
{% if saved_settings.module_retailcrm_apiversion is defined and saved_settings.module_retailcrm_apiversion != 'v3' %} -
- {{ special_price_settings }} -
- -
- +
+ {{ special_price_settings }} +
+ {% for customerGroup in customerGroups %} + {% set cud = customerGroup.customer_group_id %} +
+ +
+ +
+
+ {% endfor %}
-
-
+ {% endif %}
{{ order_number }} @@ -156,16 +161,16 @@
@@ -179,36 +184,36 @@
- {% if delivery.opencart is not empty %} - {% for value in delivery.opencart %} -
-
{{ value.title ~ ':' }}
- {% for key, val in value %} - {% if key != 'title' %} -
-
- -
-
- -
+ {% if delivery.opencart is not empty %} + {% for value in delivery.opencart %} +
+
{{ value.title ~ ':' }}
+ {% for key, val in value %} + {% if key != 'title' %} +
+
+ +
+
+ +
+
+ {% endif %} + {% endfor %}
- {% endif %} - {% endfor %} + {% endfor %} + {% else %} +
+ + {{ text_error_delivery }}
- {% endfor %} - {% else %} -
- - {{ text_error_delivery }} -
- {% endif %} + {% endif %}
@@ -216,21 +221,21 @@
{% for status in statuses.opencart %} - {% set uid = status.order_status_id %} -
-
- + {% set uid = status.order_status_id %} +
+
+ +
+
+ +
-
- -
-
{% endfor %}
@@ -238,20 +243,20 @@
{% for key, value in payments.opencart %} -
-
- +
+
+ +
+
+ +
-
- -
-
{% endfor %}
@@ -264,9 +269,9 @@
@@ -280,15 +285,15 @@
@@ -308,9 +313,9 @@
@@ -325,17 +330,17 @@
{{ daemon_collector }}
- +
@@ -352,13 +357,13 @@
@@ -383,37 +388,37 @@
- +
{% for field, label in collectorFields %} -
- -
-
-
- -
-
- - +
+ +
+
+
+ +
+
+ + +
-
{% endfor %}
@@ -427,14 +432,14 @@
@@ -444,21 +449,21 @@
{% for customField in customFields.opencart %} -
-
- {% set fid = 'c_' ~ customField.custom_field_id %} -
- +
+
+ {% set fid = 'c_' ~ customField.custom_field_id %} +
+ +
+
-
-
{% endfor %}
@@ -468,21 +473,21 @@
{% for customField in customFields.opencart %} -
-
- {% set fid = 'o_' ~ customField.custom_field_id %} -
- +
+
+ {% set fid = 'o_' ~ customField.custom_field_id %} +
+ +
+
-
-
{% endfor %}
@@ -513,11 +518,11 @@
{% if logs.retailcrm_log is defined %} -
-
- +
+
+ +
-
{% elseif logs.retailcrm_error is defined %}
{{ logs.retailcrm_error }} @@ -530,11 +535,11 @@
{% if logs.oc_api_log is defined %} -
-
- +
+
+ +
-
{% elseif logs.oc_error is defined %}
{{ logs.oc_error }} diff --git a/tests/admin/ModelRetailcrmPricesAdminTest.php b/tests/admin/ModelRetailcrmPricesAdminTest.php index 150cfee..b98d5ae 100644 --- a/tests/admin/ModelRetailcrmPricesAdminTest.php +++ b/tests/admin/ModelRetailcrmPricesAdminTest.php @@ -17,7 +17,8 @@ class ModelRetailcrmPricesAdminTest extends OpenCartTest ->disableOriginalConstructor() ->setMethods(array( 'storePricesUpload', - 'sitesList' + 'sitesList', + 'isSuccessful' )) ->getMock(); @@ -28,13 +29,23 @@ class ModelRetailcrmPricesAdminTest extends OpenCartTest $this->retailcrm->getModuleTitle(), array( $this->retailcrm->getModuleTitle() . '_apiversion' => 'v5', - $this->retailcrm->getModuleTitle() . '_special' => 'special' + $this->retailcrm->getModuleTitle() . '_special_1' => 'special1', + $this->retailcrm->getModuleTitle() . '_special_2' => 'special2' ) ); } public function testUploadPrices() { + + $response = new \RetailcrmApiResponse( + 201, + json_encode( + $this->sites() + ) + ); + + $this->apiClientMock->expects($this->any())->method('sitesList')->willReturn($response); $productModel = $this->loadModel('catalog/product'); $products = $productModel->getProducts(); $prices = $this->pricesModel->uploadPrices($products, $this->apiClientMock); @@ -48,4 +59,30 @@ class ModelRetailcrmPricesAdminTest extends OpenCartTest $this->assertArrayHasKey('prices', $price); $this->assertInternalType('array', $price['prices']); } + + private function sites(){ + return array( + "success"=> true, + "sites"=> array( + "BitrixMod"=> array( + "name"=> "site", + "url"=> "http://site.ru", + "code"=> "site", + "defaultForCrm"=> false, + "ymlUrl"=> "http://site.ru/retailcrm.xml", + "loadFromYml"=> false, + "catalogUpdatedAt"=> "2019-02-08 13:30:37", + "catalogLoadingAt"=> "2019-02-11 09:12:18", + "contragent"=> array( + "contragentType"=> "legal-entity", + "legalName"=> "code", + "code"=> "code", + "countryIso"=> "RU", + "vatRate"=> "", + ), + "countryIso"=> "", + ) + ), + ); + } } \ No newline at end of file From 8a823cf3ad4429e8cc7781a59a9cf63bb0799973 Mon Sep 17 00:00:00 2001 From: Sergey Date: Thu, 28 Feb 2019 16:28:07 +0300 Subject: [PATCH 2/4] =?UTF-8?q?v3.2.4=20=D0=9E=D1=82=D0=BF=D1=80=D0=B0?= =?UTF-8?q?=D0=B2=D0=BA=D0=B0=20=D0=BD=D1=83=D0=BB=D0=B5=D0=B2=D0=BE=D0=B9?= =?UTF-8?q?=20=D1=86=D0=B5=D0=BD=D1=8B=20=D0=BF=D1=80=D0=B8=20=D0=BE=D1=82?= =?UTF-8?q?=D1=81=D1=83=D1=82=D1=81=D0=B2=D1=82=D1=83=D1=8E=D1=89=D0=B5?= =?UTF-8?q?=D0=B9=20=D0=B0=D0=BA=D1=86=D0=B8=D0=BE=D0=BD=D0=BD=D0=BE=D0=B9?= =?UTF-8?q?=20=D1=86=D0=B5=D0=BD=D0=B5?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- CHANGELOG.md | 4 +- .../model/extension/retailcrm/prices.php | 142 ++++++++++++------ .../template/extension/module/retailcrm.tpl | 2 +- .../template/extension/module/retailcrm.twig | 2 +- tests/admin/ModelRetailcrmPricesAdminTest.php | 7 +- tests/opencart_sample_data.sql | 6 + 6 files changed, 109 insertions(+), 54 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index e9c6bbc..0318268 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,7 @@ ## v.3.2.4 -* Изменена передача типов цен с учетом групп пользователей на сайте +* Добавлена возможность передачи акционных цен для нескольких групп пользователей +* Добавлена передача нулевой цены для неустановленных акционных цен +* Убрана базовая цена retailcrm из настроек соответствия типов цен ## v.3.2.2 * Убрана генерация externalId покупателя при заказе без регистрации на сайте. diff --git a/src/upload/admin/model/extension/retailcrm/prices.php b/src/upload/admin/model/extension/retailcrm/prices.php index 36a95f2..c7b9a1e 100644 --- a/src/upload/admin/model/extension/retailcrm/prices.php +++ b/src/upload/admin/model/extension/retailcrm/prices.php @@ -45,7 +45,6 @@ class ModelExtensionRetailcrmPrices extends Model $retailcrmApiClient->storePricesUpload($priceUpload); } - return $pricesUpload; } @@ -69,71 +68,89 @@ class ModelExtensionRetailcrmPrices extends Model $specials = $this->model_catalog_product->getProductSpecials($product['product_id']); if (!$specials) { - continue; + $productPrice = $this->getEmptyPrice(); + $prices[] = $this->getPriceRequest($product, $site, $productPrice, true); } $productPrice = array(); if (is_array($specials) && count($specials)) { - $productPrice = $this->getSpecialPrice($specials); + $productPrice = ModelExtensionRetailcrmPrices::getSpecialPrice($specials); } if (empty($productPrice)) { continue; } - $offers = $this->retailcrm->getOffers($product); - - foreach ($offers as $optionsString => $optionsValues) { - $optionsString = explode('_', $optionsString); - $options = array(); - - foreach($optionsString as $optionString) { - $option = explode('-', $optionString); - $optionIds = explode(':', $option[0]); - - if ($optionString != '0:0-0') { - $optionData = $this->getOptionData($optionIds[1], $option[1]); - $options[$optionIds[0]] = array( - 'name' => $optionData['optionName'], - 'value' => $optionData['optionValue'], - 'value_id' => $option[1] - ); - } - } - - ksort($options); - - $offerId = array(); - - foreach($options as $optionKey => $optionData) { - $offerId[] = $optionKey.'-'.$optionData['value_id']; - } - - $offerId = implode('_', $offerId); - $price = array(); - - foreach($productPrice as $k => $v) { - if (isset($this->settings[$this->moduleTitle . '_special_' . $k])) { - $price[] = array( - 'code' => $this->settings[$this->moduleTitle . '_special_' . $k], - 'price' => $v + $optionsValues['price'] - ); - } - } - - $prices[] = array( - 'externalId' => $offerId ? $product['product_id'] . '#' . $offerId : $product['product_id'], - 'site' => $site, - 'prices' => $price - ); - - } + $prices[] = $this->getPriceRequest($product, $site, $productPrice); } return $prices; } + /** + * Get prices for request + * + * @param $product + * @param $site + * @param $specials + * @param bool $noSpecials + * + * @return array + */ + private function getPriceRequest($product, $site, $productPrice) + { + $offers = $this->retailcrm->getOffers($product); + $pricesProduct = array(); + + foreach ($offers as $optionsString => $optionsValues) { + $optionsString = explode('_', $optionsString); + $options = array(); + + foreach($optionsString as $optionString) { + $option = explode('-', $optionString); + $optionIds = explode(':', $option[0]); + + if ($optionString != '0:0-0') { + $optionData = $this->getOptionData($optionIds[1], $option[1]); + $options[$optionIds[0]] = array( + 'name' => $optionData['optionName'], + 'value' => $optionData['optionValue'], + 'value_id' => $option[1] + ); + } + } + + ksort($options); + + $offerId = array(); + + foreach($options as $optionKey => $optionData) { + $offerId[] = $optionKey.'-'.$optionData['value_id']; + } + + $offerId = implode('_', $offerId); + $price = array(); + + foreach($productPrice as $k => $v) { + if (isset($this->settings[$this->moduleTitle . '_special_' . $k])) { + $price[] = array( + 'code' => $this->settings[$this->moduleTitle . '_special_' . $k], + 'price' => $v == 0 ? $v : $v + $optionsValues['price'] + ); + } + } + + $pricesProduct = array( + 'externalId' => $offerId ? $product['product_id'] . '#' . $offerId : $product['product_id'], + 'site' => $site, + 'prices' => $price + ); + } + + return $pricesProduct; + } + /** * Get actual special * @@ -166,6 +183,31 @@ class ModelExtensionRetailcrmPrices extends Model } } + $customerGroups = $this->model_customer_customer_group->getCustomerGroups(); + + foreach ($customerGroups as $customerGroup) { + if (!isset($productPrice[$customerGroup['customer_group_id']])){ + $productPrice[$customerGroup['customer_group_id']] = 0; + } + } + + return $productPrice; + } + + /** + * Get price for no special + * + * @return array $productPrice + */ + private function getEmptyPrice() + { + $customerGroups = $this->model_customer_customer_group->getCustomerGroups(); + $productPrice = array(); + + foreach ($customerGroups as $customerGroup) { + $productPrice[$customerGroup['customer_group_id']] = 0; + } + return $productPrice; } diff --git a/src/upload/admin/view/template/extension/module/retailcrm.tpl b/src/upload/admin/view/template/extension/module/retailcrm.tpl index 6804a93..af02012 100644 --- a/src/upload/admin/view/template/extension/module/retailcrm.tpl +++ b/src/upload/admin/view/template/extension/module/retailcrm.tpl @@ -142,7 +142,7 @@
{% for priceType in priceTypes %} - {% if priceType.active == true %} + {% if priceType.active == true and priceType.default == false%} diff --git a/tests/admin/ModelRetailcrmPricesAdminTest.php b/tests/admin/ModelRetailcrmPricesAdminTest.php index b98d5ae..7a7ad01 100644 --- a/tests/admin/ModelRetailcrmPricesAdminTest.php +++ b/tests/admin/ModelRetailcrmPricesAdminTest.php @@ -30,7 +30,8 @@ class ModelRetailcrmPricesAdminTest extends OpenCartTest array( $this->retailcrm->getModuleTitle() . '_apiversion' => 'v5', $this->retailcrm->getModuleTitle() . '_special_1' => 'special1', - $this->retailcrm->getModuleTitle() . '_special_2' => 'special2' + $this->retailcrm->getModuleTitle() . '_special_2' => 'special2', + $this->retailcrm->getModuleTitle() . '_special_3' => 'special3' ) ); } @@ -58,6 +59,10 @@ class ModelRetailcrmPricesAdminTest extends OpenCartTest $this->assertArrayHasKey('site', $price); $this->assertArrayHasKey('prices', $price); $this->assertInternalType('array', $price['prices']); + $this->assertEquals('special1', $price['prices'][0]['code']); + $this->assertEquals('special2', $price['prices'][1]['code']); + $this->assertEquals('special3', $price['prices'][2]['code']); + $this->assertEquals(0, $price['prices'][2]['price']); } private function sites(){ diff --git a/tests/opencart_sample_data.sql b/tests/opencart_sample_data.sql index cb4812d..c3c3057 100644 --- a/tests/opencart_sample_data.sql +++ b/tests/opencart_sample_data.sql @@ -4,9 +4,13 @@ INSERT INTO `oc_customer` (`customer_id`, `customer_group_id`, `store_id`, `lang TRUNCATE TABLE `oc_customer_activity`; TRUNCATE TABLE `oc_customer_group`; INSERT INTO `oc_customer_group` (`customer_group_id`, `approval`, `sort_order`) VALUES ('1', '0', '1'); +INSERT INTO `oc_customer_group` (`customer_group_id`, `approval`, `sort_order`) VALUES ('2', '0', '1'); +INSERT INTO `oc_customer_group` (`customer_group_id`, `approval`, `sort_order`) VALUES ('3', '0', '0'); TRUNCATE TABLE `oc_customer_group_description`; INSERT INTO `oc_customer_group_description` (`customer_group_id`, `language_id`, `name`, `description`) VALUES ('1', '1', 'Default', 'test'); +INSERT INTO `oc_customer_group_description` (`customer_group_id`, `language_id`, `name`, `description`) VALUES ('2', '1', 'Test2', 'test2'); +INSERT INTO `oc_customer_group_description` (`customer_group_id`, `language_id`, `name`, `description`) VALUES ('3', '1', 'test3', 'test3'); TRUNCATE TABLE `oc_customer_history`; TRUNCATE TABLE `oc_customer_ip`; @@ -39,11 +43,13 @@ INSERT INTO `oc_order_product` (`order_product_id`, `order_id`, `product_id`, `n TRUNCATE TABLE `oc_order_recurring`; TRUNCATE TABLE `oc_order_recurring_transaction`; TRUNCATE TABLE `oc_order_total`; + INSERT INTO `oc_order_total` (`order_total_id`, `order_id`, `code`, `title`, `value`, `sort_order`) VALUES ('162', '1', 'shipping', 'Flat Rate', '5.0000', '3'); INSERT INTO `oc_order_total` (`order_total_id`, `order_id`, `code`, `title`, `value`, `sort_order`) VALUES ('161', '1', 'sub_total', 'Sub-Total', '101.0000', '1'); INSERT INTO `oc_order_total` (`order_total_id`, `order_id`, `code`, `title`, `value`, `sort_order`) VALUES ('164', '2', 'sub_total', 'Sub-Total', '80.0000', '1'); INSERT INTO `oc_order_total` (`order_total_id`, `order_id`, `code`, `title`, `value`, `sort_order`) VALUES ('165', '2', 'shipping', 'Flat Rate', '5.0000', '3'); INSERT INTO `oc_order_total` (`order_total_id`, `order_id`, `code`, `title`, `value`, `sort_order`) VALUES ('163', '1', 'total', 'Total', '106.0000', '9'); INSERT INTO `oc_order_total` (`order_total_id`, `order_id`, `code`, `title`, `value`, `sort_order`) VALUES ('166', '2', 'total', 'Total', '85.0000', '9'); +INSERT INTO `oc_product_special` (`product_id`, `customer_group_id`, `priority`, `price`,`date_start`, `date_end`) values ('42', '2', '1', '110.000', CURDATE(), ADDDATE(CURDATE(),INTERVAL 10 DAY)); TRUNCATE TABLE `oc_order_voucher`; \ No newline at end of file From 48ccded014bf5337811bb18d9c44cf2d52ec7179 Mon Sep 17 00:00:00 2001 From: Sergey Date: Fri, 1 Mar 2019 11:07:16 +0300 Subject: [PATCH 3/4] fix model prices --- src/upload/admin/model/extension/retailcrm/prices.php | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/src/upload/admin/model/extension/retailcrm/prices.php b/src/upload/admin/model/extension/retailcrm/prices.php index c7b9a1e..b666769 100644 --- a/src/upload/admin/model/extension/retailcrm/prices.php +++ b/src/upload/admin/model/extension/retailcrm/prices.php @@ -69,7 +69,7 @@ class ModelExtensionRetailcrmPrices extends Model if (!$specials) { $productPrice = $this->getEmptyPrice(); - $prices[] = $this->getPriceRequest($product, $site, $productPrice, true); + $prices[] = $this->getPriceRequest($product, $site, $productPrice); } $productPrice = array(); @@ -93,8 +93,7 @@ class ModelExtensionRetailcrmPrices extends Model * * @param $product * @param $site - * @param $specials - * @param bool $noSpecials + * @param $productPrice * * @return array */ From 9fedcb096c9ee12d5bf390216241b8fd3aa05c4d Mon Sep 17 00:00:00 2001 From: Sergey Date: Fri, 1 Mar 2019 14:27:46 +0300 Subject: [PATCH 4/4] fix model prices --- src/upload/admin/model/extension/retailcrm/prices.php | 7 ++----- 1 file changed, 2 insertions(+), 5 deletions(-) diff --git a/src/upload/admin/model/extension/retailcrm/prices.php b/src/upload/admin/model/extension/retailcrm/prices.php index b666769..20a0fb1 100644 --- a/src/upload/admin/model/extension/retailcrm/prices.php +++ b/src/upload/admin/model/extension/retailcrm/prices.php @@ -70,16 +70,13 @@ class ModelExtensionRetailcrmPrices extends Model if (!$specials) { $productPrice = $this->getEmptyPrice(); $prices[] = $this->getPriceRequest($product, $site, $productPrice); + continue; } $productPrice = array(); if (is_array($specials) && count($specials)) { - $productPrice = ModelExtensionRetailcrmPrices::getSpecialPrice($specials); - } - - if (empty($productPrice)) { - continue; + $productPrice = $this->getSpecialPrice($specials); } $prices[] = $this->getPriceRequest($product, $site, $productPrice);