From 41da8fe8629c353c8522ebf2e57db3fddd41ab35 Mon Sep 17 00:00:00 2001 From: Akolzin Dmitry Date: Fri, 10 Apr 2020 11:36:10 +0300 Subject: [PATCH 1/2] Fix for 3.0 installation, fixes pricing in ICML --- .docker/Dockerfile | 28 +++++++++++++ .env-dist | 5 ++- CHANGELOG.md | 6 +++ Makefile | 12 ++++++ VERSION | 2 +- composer.json | 2 +- docker-compose.yml | 40 +++++++++++++++++++ .../system/library/retailcrm/retailcrm.php | 20 ++++++++-- tests/RoboFile.php | 14 +++++++ 9 files changed, 122 insertions(+), 7 deletions(-) create mode 100644 .docker/Dockerfile create mode 100644 docker-compose.yml diff --git a/.docker/Dockerfile b/.docker/Dockerfile new file mode 100644 index 0000000..e0fb8a8 --- /dev/null +++ b/.docker/Dockerfile @@ -0,0 +1,28 @@ +FROM php:7.1-cli + +RUN apt-get update + +RUN apt-get install -y zlib1g-dev libpq-dev git libicu-dev libxml2-dev libpng-dev libjpeg-dev libmcrypt-dev libxslt-dev libfreetype6-dev \ + && docker-php-ext-configure intl \ + && docker-php-ext-install intl \ + && docker-php-ext-configure pgsql -with-pgsql=/usr/local/pgsql \ + && docker-php-ext-install mysqli pdo pdo_mysql \ + && docker-php-ext-install zip \ + && docker-php-ext-install xml \ + && docker-php-ext-configure gd --with-png-dir=/usr/local/ --with-jpeg-dir=/usr/local/ --with-freetype-dir=/usr/local/ \ + && docker-php-ext-install gd \ + && docker-php-ext-install mcrypt \ + && docker-php-ext-install bcmath \ + && docker-php-ext-install soap \ + && docker-php-ext-install xsl \ + && docker-php-ext-install mbstring + +RUN apt-get install -y wget + +RUN wget -O /usr/bin/phpunit https://phar.phpunit.de/phpunit-7.phar && chmod +x /usr/bin/phpunit +RUN curl --insecure https://getcomposer.org/download/1.9.3/composer.phar -o /usr/bin/composer && chmod +x /usr/bin/composer + +# Set timezone +RUN rm /etc/localtime +RUN ln -s /usr/share/zoneinfo/Europe/Moscow /etc/localtime +RUN "date" diff --git a/.env-dist b/.env-dist index 1e22668..05c05b6 100644 --- a/.env-dist +++ b/.env-dist @@ -11,5 +11,8 @@ OC_PASSWORD=admin OC_EMAIL=you@example.com # Server Specification -SERVER_PORT=8000 +SERVER_PORT=80 SERVER_URL=http://localhost + +TEST_SUITE= +OPENCART= diff --git a/CHANGELOG.md b/CHANGELOG.md index a0be130..a559b00 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,3 +1,9 @@ +## v.3.3.9 +* Исправлены цены в ICML + +## v.3.3.8 +* Исправлен вывод предупреждений при генерации ICML + ## v.3.3.7 * Изменена конфигурация travis-ci для сборки diff --git a/Makefile b/Makefile index 5066fb9..6b36c43 100644 --- a/Makefile +++ b/Makefile @@ -26,3 +26,15 @@ before_script: coverage: wget https://phar.phpunit.de/phpcov-2.0.2.phar && php phpcov-2.0.2.phar merge coverage/ --clover coverage.xml + +robo_deploy: + bin/robo --load-from tests/RoboFile.php project:deploy + +run_test: + composer require --dev beyondit/opencart-test-suite ~$(TEST_SUITE) + composer require --dev opencart/opencart $(OPENCART) + composer setup + bin/robo --load-from tests/RoboFile.php project:deploy + (php -S localhost:80 -t www &) 2> /dev/null > /dev/null + sleep 2 + composer test diff --git a/VERSION b/VERSION index 37d02a6..3b47f2e 100644 --- a/VERSION +++ b/VERSION @@ -1 +1 @@ -3.3.8 +3.3.9 diff --git a/composer.json b/composer.json index fc8517e..a15a455 100644 --- a/composer.json +++ b/composer.json @@ -1,6 +1,6 @@ { "name": "retailcrm/opencart-module", - "description": "Integration module for Opencart & RetailCRM", + "description": "Integration module for Opencart & retailCRM", "license": "GPL-3.0", "type": "project", "authors": [ diff --git a/docker-compose.yml b/docker-compose.yml new file mode 100644 index 0000000..1fccab4 --- /dev/null +++ b/docker-compose.yml @@ -0,0 +1,40 @@ +version: '3' +services: + app: + build: + context: ./.docker + volumes: + - ./:/home/code + links: + - "mysql" + user: ${UID:-1000}:${GID:-1000} + depends_on: + - mysql + env_file: + - ./.env + environment: + - OC_DB_HOSTNAME=${OC_DB_HOSTNAME} + - OC_DB_USERNAME=${OC_DB_USERNAME} + - OC_DB_PASSWORD=${OC_DB_PASSWORD} + - OC_DB_DATABASE=${OC_DB_DATABASE} + - OC_DB_DRIVER=${OC_DB_DRIVER} + - OC_USERNAME=${OC_USERNAME} + - OC_PASSWORD=${OC_PASSWORD} + - OC_EMAIL=${OC_EMAIL} + - SERVER_PORT=${SERVER_PORT} + - SERVER_URL=${SERVER_URL} + - TEST_SUITE=${TEST_SUITE} + - OPENCART=${OPENCART} + command: make run + working_dir: /home/code + mysql: + image: mysql:5.7 + env_file: + - ./.env + environment: + - MYSQL_DATABASE=${OC_DB_DATABASE} + - MYSQL_USER=${OC_DB_USERNAME} + - MYSQL_PASSWORD=${OC_DB_PASSWORD} + - MYSQL_ROOT_PASSWORD=root + ports: + - "3306:3306" diff --git a/src/upload/system/library/retailcrm/retailcrm.php b/src/upload/system/library/retailcrm/retailcrm.php index 1e85153..8a76040 100644 --- a/src/upload/system/library/retailcrm/retailcrm.php +++ b/src/upload/system/library/retailcrm/retailcrm.php @@ -114,7 +114,7 @@ class Retailcrm { if(empty($offers)) { foreach($requiredOption['product_option_value'] as $optionValue) { $offers[$requiredOption['product_option_id'].':'.$requiredOption['option_id'].'-'.$optionValue['option_value_id']] = array( - 'price' => (float)$optionValue['price'], + 'price' => (float)$this->getOptionPrice($optionValue), 'qty' => $optionValue['quantity'] ); } @@ -123,7 +123,7 @@ class Retailcrm { unset($offers[$optionKey]); // Работая в контексте обязательных опций не забываем удалять прошлые обязательные опции, т.к. они должны быть скомбинированы с другими обязательными опциями foreach($requiredOption['product_option_value'] as $optionValue) { $offers[$optionKey.'_'.$requiredOption['product_option_id'].':'.$requiredOption['option_id'].'-'.$optionValue['option_value_id']] = array( - 'price' => $optionAttr['price'] + (float)$optionValue['price'], + 'price' => $optionAttr['price'] + (float)$this->getOptionPrice($optionValue), 'qty' => ($optionAttr['qty'] > $optionValue['quantity']) ? $optionValue['quantity'] : $optionAttr['qty'] ); @@ -139,7 +139,7 @@ class Retailcrm { $offers['0:0-0'] = 0; // В случае работы с необязательными опциями мы должны учитывать товарное предложение без опций, поэтому создадим "пустую" опцию foreach($notRequiredOption['product_option_value'] as $optionValue) { $offers[$notRequiredOption['product_option_id'].':'.$notRequiredOption['option_id'].'-'.$optionValue['option_value_id']] = array( - 'price' => (float)$optionValue['price'], + 'price' => (float)$this->getOptionPrice($optionValue), 'qty' => $optionValue['quantity'] ); } @@ -147,7 +147,7 @@ class Retailcrm { foreach($offers as $optionKey => $optionAttr) { foreach($notRequiredOption['product_option_value'] as $optionValue) { $offers[$optionKey.'_'.$notRequiredOption['product_option_id'].':'.$notRequiredOption['option_id'].'-'.$optionValue['option_value_id']] = array( - 'price' => $optionAttr['price'] + (float)$optionValue['price'], + 'price' => $optionAttr['price'] + (float)$this->getOptionPrice($optionValue), 'qty' => ($optionAttr['qty'] > $optionValue['quantity']) ? $optionValue['quantity'] : $optionAttr['qty'] ); @@ -163,6 +163,18 @@ class Retailcrm { return $offers; } + /** + * @param array $optionValue + * @return float|int|mixed + */ + private function getOptionPrice($optionValue) { + if ($optionValue['price_prefix'] === '-') { + return $optionValue['price'] * -1; + } + + return $optionValue['price']; + } + /** * @return mixed */ diff --git a/tests/RoboFile.php b/tests/RoboFile.php index 7313c66..65d85f8 100644 --- a/tests/RoboFile.php +++ b/tests/RoboFile.php @@ -112,6 +112,20 @@ class RoboFile extends \Robo\Tasks $this->printTaskError(" Could not connect ot database..."); } + $install_code = file_get_contents($this->root_dir . 'www/install/cli_install.php'); + $storage = <<root_dir . 'www/install/cli_install.php', + str_replace("define('DIR_MODIFICATION', DIR_SYSTEM . 'modification/');", $storage, $install_code) + ); + $install = $this->taskExec('php')->arg($this->root_dir . 'www/install/cli_install.php')->arg('install'); foreach ($this->opencart_config as $option => $value) { $install->option($option, $value); From ce07e06b55f4bb3847092b85b2df4280057c6e3a Mon Sep 17 00:00:00 2001 From: Akolzin Dmitry Date: Fri, 10 Apr 2020 11:51:17 +0300 Subject: [PATCH 2/2] installation fix --- tests/RoboFile.php | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) diff --git a/tests/RoboFile.php b/tests/RoboFile.php index 65d85f8..63e723c 100644 --- a/tests/RoboFile.php +++ b/tests/RoboFile.php @@ -112,19 +112,19 @@ class RoboFile extends \Robo\Tasks $this->printTaskError(" Could not connect ot database..."); } - $install_code = file_get_contents($this->root_dir . 'www/install/cli_install.php'); - $storage = <<root_dir . 'www/install/cli_install.php', - str_replace("define('DIR_MODIFICATION', DIR_SYSTEM . 'modification/');", $storage, $install_code) - ); + file_put_contents( + $this->root_dir . 'www/install/cli_install.php', + str_replace("define('DIR_MODIFICATION', DIR_SYSTEM . 'modification/');", $storage, $install_code) + ); + } $install = $this->taskExec('php')->arg($this->root_dir . 'www/install/cli_install.php')->arg('install'); foreach ($this->opencart_config as $option => $value) {