Merge pull request #180 from iyzoer/master

Fix for 3.0 installation, fixes pricing in ICML
This commit is contained in:
Alex Lushpai 2020-04-10 12:42:47 +03:00 committed by GitHub
commit b57ff08d31
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
9 changed files with 122 additions and 7 deletions

28
.docker/Dockerfile Normal file
View File

@ -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"

View File

@ -11,5 +11,8 @@ OC_PASSWORD=admin
OC_EMAIL=you@example.com OC_EMAIL=you@example.com
# Server Specification # Server Specification
SERVER_PORT=8000 SERVER_PORT=80
SERVER_URL=http://localhost SERVER_URL=http://localhost
TEST_SUITE=
OPENCART=

View File

@ -1,3 +1,9 @@
## v.3.3.9
* Исправлены цены в ICML
## v.3.3.8
* Исправлен вывод предупреждений при генерации ICML
## v.3.3.7 ## v.3.3.7
* Изменена конфигурация travis-ci для сборки * Изменена конфигурация travis-ci для сборки

View File

@ -26,3 +26,15 @@ before_script:
coverage: coverage:
wget https://phar.phpunit.de/phpcov-2.0.2.phar && php phpcov-2.0.2.phar merge coverage/ --clover coverage.xml 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

View File

@ -1 +1 @@
3.3.8 3.3.9

View File

@ -1,6 +1,6 @@
{ {
"name": "retailcrm/opencart-module", "name": "retailcrm/opencart-module",
"description": "Integration module for Opencart & RetailCRM", "description": "Integration module for Opencart & retailCRM",
"license": "GPL-3.0", "license": "GPL-3.0",
"type": "project", "type": "project",
"authors": [ "authors": [

40
docker-compose.yml Normal file
View File

@ -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"

View File

@ -114,7 +114,7 @@ class Retailcrm {
if(empty($offers)) { if(empty($offers)) {
foreach($requiredOption['product_option_value'] as $optionValue) { foreach($requiredOption['product_option_value'] as $optionValue) {
$offers[$requiredOption['product_option_id'].':'.$requiredOption['option_id'].'-'.$optionValue['option_value_id']] = array( $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'] 'qty' => $optionValue['quantity']
); );
} }
@ -123,7 +123,7 @@ class Retailcrm {
unset($offers[$optionKey]); // Работая в контексте обязательных опций не забываем удалять прошлые обязательные опции, т.к. они должны быть скомбинированы с другими обязательными опциями unset($offers[$optionKey]); // Работая в контексте обязательных опций не забываем удалять прошлые обязательные опции, т.к. они должны быть скомбинированы с другими обязательными опциями
foreach($requiredOption['product_option_value'] as $optionValue) { foreach($requiredOption['product_option_value'] as $optionValue) {
$offers[$optionKey.'_'.$requiredOption['product_option_id'].':'.$requiredOption['option_id'].'-'.$optionValue['option_value_id']] = array( $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']) ? 'qty' => ($optionAttr['qty'] > $optionValue['quantity']) ?
$optionValue['quantity'] : $optionAttr['qty'] $optionValue['quantity'] : $optionAttr['qty']
); );
@ -139,7 +139,7 @@ class Retailcrm {
$offers['0:0-0'] = 0; // В случае работы с необязательными опциями мы должны учитывать товарное предложение без опций, поэтому создадим "пустую" опцию $offers['0:0-0'] = 0; // В случае работы с необязательными опциями мы должны учитывать товарное предложение без опций, поэтому создадим "пустую" опцию
foreach($notRequiredOption['product_option_value'] as $optionValue) { foreach($notRequiredOption['product_option_value'] as $optionValue) {
$offers[$notRequiredOption['product_option_id'].':'.$notRequiredOption['option_id'].'-'.$optionValue['option_value_id']] = array( $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'] 'qty' => $optionValue['quantity']
); );
} }
@ -147,7 +147,7 @@ class Retailcrm {
foreach($offers as $optionKey => $optionAttr) { foreach($offers as $optionKey => $optionAttr) {
foreach($notRequiredOption['product_option_value'] as $optionValue) { foreach($notRequiredOption['product_option_value'] as $optionValue) {
$offers[$optionKey.'_'.$notRequiredOption['product_option_id'].':'.$notRequiredOption['option_id'].'-'.$optionValue['option_value_id']] = array( $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']) ? 'qty' => ($optionAttr['qty'] > $optionValue['quantity']) ?
$optionValue['quantity'] : $optionAttr['qty'] $optionValue['quantity'] : $optionAttr['qty']
); );
@ -163,6 +163,18 @@ class Retailcrm {
return $offers; 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 * @return mixed
*/ */

View File

@ -112,6 +112,20 @@ class RoboFile extends \Robo\Tasks
$this->printTaskError("<error> Could not connect ot database..."); $this->printTaskError("<error> Could not connect ot database...");
} }
if (version_compare(getenv('OPENCART'), '3.0.2.0', '<=')) {
$install_code = file_get_contents($this->root_dir . 'www/install/cli_install.php');
$storage = <<<EOF
define('DIR_MODIFICATION', DIR_SYSTEM . 'modification/');
define('DIR_STORAGE', DIR_SYSTEM . 'storage/');
EOF;
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'); $install = $this->taskExec('php')->arg($this->root_dir . 'www/install/cli_install.php')->arg('install');
foreach ($this->opencart_config as $option => $value) { foreach ($this->opencart_config as $option => $value) {
$install->option($option, $value); $install->option($option, $value);