mirror of
https://github.com/retailcrm/opencart-module.git
synced 2024-11-25 06:36:06 +03:00
Merge pull request #180 from iyzoer/master
Fix for 3.0 installation, fixes pricing in ICML
This commit is contained in:
commit
b57ff08d31
28
.docker/Dockerfile
Normal file
28
.docker/Dockerfile
Normal 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"
|
@ -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=
|
||||
|
@ -1,3 +1,9 @@
|
||||
## v.3.3.9
|
||||
* Исправлены цены в ICML
|
||||
|
||||
## v.3.3.8
|
||||
* Исправлен вывод предупреждений при генерации ICML
|
||||
|
||||
## v.3.3.7
|
||||
* Изменена конфигурация travis-ci для сборки
|
||||
|
||||
|
12
Makefile
12
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
|
||||
|
@ -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": [
|
||||
|
40
docker-compose.yml
Normal file
40
docker-compose.yml
Normal 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"
|
@ -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
|
||||
*/
|
||||
|
@ -112,6 +112,20 @@ class RoboFile extends \Robo\Tasks
|
||||
$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');
|
||||
foreach ($this->opencart_config as $option => $value) {
|
||||
$install->option($option, $value);
|
||||
|
Loading…
Reference in New Issue
Block a user