Compare commits
No commits in common. "master" and "v2.5.0" have entirely different histories.
54 changed files with 207 additions and 1313 deletions
234
.github/workflows/magento.yml
vendored
234
.github/workflows/magento.yml
vendored
|
@ -1,234 +0,0 @@
|
||||||
# This is a basic workflow to help you get started with Actions
|
|
||||||
|
|
||||||
name: magento
|
|
||||||
|
|
||||||
on:
|
|
||||||
push:
|
|
||||||
branches:
|
|
||||||
- '**'
|
|
||||||
tags-ignore:
|
|
||||||
- '*.*'
|
|
||||||
pull_request:
|
|
||||||
|
|
||||||
jobs:
|
|
||||||
test:
|
|
||||||
runs-on: ubuntu-latest
|
|
||||||
strategy:
|
|
||||||
matrix:
|
|
||||||
include:
|
|
||||||
- php-version: '7.0'
|
|
||||||
branch: '2.0.2'
|
|
||||||
coverage: 1
|
|
||||||
- php-version: '7.0'
|
|
||||||
branch: '2.0.4'
|
|
||||||
- php-version: '7.0'
|
|
||||||
branch: '2.0.5'
|
|
||||||
- php-version: '7.0'
|
|
||||||
branch: '2.0.6'
|
|
||||||
- php-version: '7.0'
|
|
||||||
branch: '2.0.7'
|
|
||||||
- php-version: '7.0'
|
|
||||||
branch: '2.0.8'
|
|
||||||
- php-version: '7.0'
|
|
||||||
branch: '2.0.9'
|
|
||||||
- php-version: '7.0'
|
|
||||||
branch: '2.0.10'
|
|
||||||
- php-version: '7.0'
|
|
||||||
branch: '2.0.11'
|
|
||||||
- php-version: '7.0'
|
|
||||||
branch: '2.0.12'
|
|
||||||
- php-version: '7.0'
|
|
||||||
branch: '2.0.13'
|
|
||||||
- php-version: '7.0'
|
|
||||||
branch: '2.0.14'
|
|
||||||
- php-version: '7.0'
|
|
||||||
branch: '2.0.15'
|
|
||||||
- php-version: '7.0'
|
|
||||||
branch: '2.0.16'
|
|
||||||
- php-version: '7.0'
|
|
||||||
branch: '2.0.17'
|
|
||||||
- php-version: '7.0'
|
|
||||||
branch: '2.0.18'
|
|
||||||
|
|
||||||
- php-version: '7.0'
|
|
||||||
branch: '2.1.0'
|
|
||||||
- php-version: '7.0'
|
|
||||||
branch: '2.1.1'
|
|
||||||
- php-version: '7.0'
|
|
||||||
branch: '2.1.2'
|
|
||||||
- php-version: '7.0'
|
|
||||||
branch: '2.1.3'
|
|
||||||
- php-version: '7.0'
|
|
||||||
branch: '2.1.4'
|
|
||||||
- php-version: '7.0'
|
|
||||||
branch: '2.1.5'
|
|
||||||
- php-version: '7.0'
|
|
||||||
branch: '2.1.6'
|
|
||||||
- php-version: '7.0'
|
|
||||||
branch: '2.1.7'
|
|
||||||
- php-version: '7.0'
|
|
||||||
branch: '2.1.8'
|
|
||||||
- php-version: '7.0'
|
|
||||||
branch: '2.1.9'
|
|
||||||
- php-version: '7.0'
|
|
||||||
branch: '2.1.10'
|
|
||||||
- php-version: '7.0'
|
|
||||||
branch: '2.1.11'
|
|
||||||
- php-version: '7.0'
|
|
||||||
branch: '2.1.12'
|
|
||||||
- php-version: '7.0'
|
|
||||||
branch: '2.1.13'
|
|
||||||
- php-version: '7.0'
|
|
||||||
branch: '2.1.14'
|
|
||||||
- php-version: '7.0'
|
|
||||||
branch: '2.1.15'
|
|
||||||
|
|
||||||
- php-version: '7.0'
|
|
||||||
branch: '2.1.16'
|
|
||||||
- php-version: '7.1'
|
|
||||||
branch: '2.1.16'
|
|
||||||
|
|
||||||
- php-version: '7.0'
|
|
||||||
branch: '2.1.17'
|
|
||||||
- php-version: '7.1'
|
|
||||||
branch: '2.1.17'
|
|
||||||
|
|
||||||
- php-version: '7.0'
|
|
||||||
branch: '2.1.18'
|
|
||||||
- php-version: '7.1'
|
|
||||||
branch: '2.1.18'
|
|
||||||
|
|
||||||
- php-version: '7.0'
|
|
||||||
branch: '2.2.0'
|
|
||||||
- php-version: '7.1'
|
|
||||||
branch: '2.2.0'
|
|
||||||
|
|
||||||
- php-version: '7.0'
|
|
||||||
branch: '2.2.1'
|
|
||||||
- php-version: '7.1'
|
|
||||||
branch: '2.2.1'
|
|
||||||
|
|
||||||
- php-version: '7.0'
|
|
||||||
branch: '2.2.2'
|
|
||||||
- php-version: '7.1'
|
|
||||||
branch: '2.2.2'
|
|
||||||
|
|
||||||
- php-version: '7.0'
|
|
||||||
branch: '2.2.3'
|
|
||||||
- php-version: '7.1'
|
|
||||||
branch: '2.2.3'
|
|
||||||
|
|
||||||
- php-version: '7.0'
|
|
||||||
branch: '2.2.4'
|
|
||||||
- php-version: '7.1'
|
|
||||||
branch: '2.2.4'
|
|
||||||
|
|
||||||
- php-version: '7.0'
|
|
||||||
branch: '2.2.5'
|
|
||||||
- php-version: '7.1'
|
|
||||||
branch: '2.2.5'
|
|
||||||
|
|
||||||
- php-version: '7.0'
|
|
||||||
branch: '2.2.6'
|
|
||||||
- php-version: '7.1'
|
|
||||||
branch: '2.2.6'
|
|
||||||
|
|
||||||
- php-version: '7.0'
|
|
||||||
branch: '2.2.7'
|
|
||||||
- php-version: '7.1'
|
|
||||||
branch: '2.2.7'
|
|
||||||
|
|
||||||
- php-version: '7.0'
|
|
||||||
branch: '2.2.8'
|
|
||||||
- php-version: '7.1'
|
|
||||||
branch: '2.2.8'
|
|
||||||
|
|
||||||
- php-version: '7.0'
|
|
||||||
branch: '2.2.9'
|
|
||||||
- php-version: '7.1'
|
|
||||||
branch: '2.2.9'
|
|
||||||
|
|
||||||
- php-version: '7.0'
|
|
||||||
branch: '2.2.10'
|
|
||||||
- php-version: '7.1'
|
|
||||||
branch: '2.2.10'
|
|
||||||
|
|
||||||
services:
|
|
||||||
mysql:
|
|
||||||
image: mysql:5.7
|
|
||||||
env:
|
|
||||||
MYSQL_ROOT_PASSWORD: root
|
|
||||||
ports:
|
|
||||||
- 3306/tcp
|
|
||||||
options: --health-cmd="mysqladmin ping" --health-interval=10s --health-timeout=5s --health-retries=5
|
|
||||||
steps:
|
|
||||||
- uses: actions/checkout@v2
|
|
||||||
- name: Setup PHP ${{ matrix.php-version }}
|
|
||||||
uses: shivammathur/setup-php@v2
|
|
||||||
with:
|
|
||||||
php-version: ${{ matrix.php-version }}
|
|
||||||
coverage: xdebug
|
|
||||||
tools: composer:v1, phpunit:6.4.3
|
|
||||||
extensions: gd, mbstring, zip, mcrypt, pdo_mysql, dom, soap, bcmath
|
|
||||||
- name: Start mysql service
|
|
||||||
run: sudo /etc/init.d/mysql start
|
|
||||||
- name: Status mysql service
|
|
||||||
run: sudo systemctl status mysql
|
|
||||||
- name: Install Magento
|
|
||||||
env:
|
|
||||||
BRANCH: ${{ matrix.branch }}
|
|
||||||
PUBLIC_KEY: ${{ secrets.PUBLIC_KEY}}
|
|
||||||
PRIVATE_KEY: ${{ secrets.PRIVATE_KEY}}
|
|
||||||
run: make before_script
|
|
||||||
- name: Run tests
|
|
||||||
run: make test
|
|
||||||
- name: Coverage
|
|
||||||
env:
|
|
||||||
COVERAGE: ${{ matrix.coverage }}
|
|
||||||
if: env.COVERAGE == 1
|
|
||||||
run: |
|
|
||||||
make coverage
|
|
||||||
bash <(curl -s https://codecov.io/bash)
|
|
||||||
|
|
||||||
deploy:
|
|
||||||
needs: ['test']
|
|
||||||
if: success() && github.event_name == 'push' && github.repository_owner == 'retailcrm' && github.ref == 'refs/heads/master'
|
|
||||||
runs-on: ubuntu-latest
|
|
||||||
steps:
|
|
||||||
- uses: actions/checkout@v2
|
|
||||||
- name: Setup PHP 7.2
|
|
||||||
uses: shivammathur/setup-php@v2
|
|
||||||
with:
|
|
||||||
php-version: '7.2'
|
|
||||||
tools: composer:v1
|
|
||||||
- name: Build release
|
|
||||||
run: |
|
|
||||||
git fetch origin --unshallow --tags
|
|
||||||
export LAST_TAG=`git describe --abbrev=0 --tags`
|
|
||||||
export VERSION=`cat VERSION`
|
|
||||||
export ARCHIVE_NAME=retailcrm-$VERSION.ocmod.zip
|
|
||||||
export ARCHIVE_PATH="/tmp/$ARCHIVE_NAME"
|
|
||||||
export RELEASE_TAG=v$VERSION
|
|
||||||
export LAST_COMMIT=`git log --oneline --format=%B -n 1 HEAD | head -n 1`
|
|
||||||
echo RELEASE_TAG=$RELEASE_TAG >> $GITHUB_ENV
|
|
||||||
echo LAST_TAG=$LAST_TAG >> $GITHUB_ENV
|
|
||||||
echo LAST_COMMIT=$LAST_COMMIT >> $GITHUB_ENV
|
|
||||||
echo ARCHIVE_PATH=$ARCHIVE_PATH >> $GITHUB_ENV
|
|
||||||
echo ARCHIVE_NAME=$ARCHIVE_NAME >> $GITHUB_ENV
|
|
||||||
make build_archive
|
|
||||||
- name: Create Release
|
|
||||||
id: create_release
|
|
||||||
uses: actions/create-release@v1
|
|
||||||
if: env.LAST_TAG != env.RELEASE_TAG
|
|
||||||
env:
|
|
||||||
GITHUB_TOKEN: ${{ secrets.TOKEN }}
|
|
||||||
with:
|
|
||||||
tag_name: ${{ env.RELEASE_TAG }}
|
|
||||||
release_name: ${{ env.RELEASE_TAG }}
|
|
||||||
body: ${{ env.LAST_COMMIT }}
|
|
||||||
draft: false
|
|
||||||
prerelease: false
|
|
||||||
- name: Cleanup
|
|
||||||
if: env.LAST_TAG != env.RELEASE_TAG
|
|
||||||
run: make delete_archive
|
|
||||||
|
|
3
.gitignore
vendored
3
.gitignore
vendored
|
@ -1,2 +1 @@
|
||||||
/nbproject/private/
|
/nbproject/private/
|
||||||
.idea
|
|
38
.travis.yml
Normal file
38
.travis.yml
Normal file
|
@ -0,0 +1,38 @@
|
||||||
|
language: php
|
||||||
|
|
||||||
|
sudo: false
|
||||||
|
|
||||||
|
env:
|
||||||
|
global:
|
||||||
|
- DB_USER=root
|
||||||
|
- DB_HOST=localhost
|
||||||
|
- DB_NAME=magento2_test
|
||||||
|
- ADMIN_FIRSTNAME=admin_firstname
|
||||||
|
- ADMIN_LASTNAME=admin_lastname
|
||||||
|
- ADMIN_EMAIL=example@email.com
|
||||||
|
- ADMIN_USER=admin
|
||||||
|
- ADMIN_PASS=admin123
|
||||||
|
|
||||||
|
matrix:
|
||||||
|
include:
|
||||||
|
- php: 7.1
|
||||||
|
env: BRANCH=2.2.8
|
||||||
|
- php: 7.2
|
||||||
|
env: BRANCH=2.2.8
|
||||||
|
- php: 7.3
|
||||||
|
env: BRANCH=2.2.8
|
||||||
|
|
||||||
|
before_script:
|
||||||
|
- bash bin/install.sh
|
||||||
|
|
||||||
|
script:
|
||||||
|
- bash bin/script.sh
|
||||||
|
|
||||||
|
deploy:
|
||||||
|
skip_cleanup: true
|
||||||
|
provider: script
|
||||||
|
script: make
|
||||||
|
on:
|
||||||
|
php: 7.2
|
||||||
|
branch: master
|
||||||
|
condition: "$DEPLOY = true"
|
|
@ -1,9 +1,3 @@
|
||||||
## 2021-01-30 v.2.5.2
|
|
||||||
* Переход на GitHub Actions
|
|
||||||
|
|
||||||
## 2020-12-17 v.2.5.1
|
|
||||||
* Ребрендинг RetailCRM
|
|
||||||
|
|
||||||
## 2018-12-25 v.2.5.0
|
## 2018-12-25 v.2.5.0
|
||||||
* Поддержка передачи в заказе нескольких позиций одного товара
|
* Поддержка передачи в заказе нескольких позиций одного товара
|
||||||
|
|
||||||
|
@ -11,13 +5,13 @@
|
||||||
* Удалена генерация externalId покупателя при заказе от незарегестрированного пользователя
|
* Удалена генерация externalId покупателя при заказе от незарегестрированного пользователя
|
||||||
|
|
||||||
## 2018-12-25 v.2.4.0
|
## 2018-12-25 v.2.4.0
|
||||||
* Добавлен функционал получения остатков из RetailCRM
|
* Добавлен функционал получения остатков из retailCRM
|
||||||
|
|
||||||
## 2018-12-25 v.2.3.2
|
## 2018-12-25 v.2.3.2
|
||||||
* Добавлена выгрузка картинок категорий товаров в ICML
|
* Добавлена выгрузка картинок категорий товаров в ICML
|
||||||
|
|
||||||
## 2018-10-25 v.2.3.1
|
## 2018-10-25 v.2.3.1
|
||||||
* Добавлена активация модуля в маркетплейсе RetailCRM
|
* Добавлена активация модуля в маркетплейсе retailCRM
|
||||||
|
|
||||||
## 2018-08-21 v.2.3.0
|
## 2018-08-21 v.2.3.0
|
||||||
* Добавлены консольные команды для выгрузки архива клиентов и заказов
|
* Добавлены консольные команды для выгрузки архива клиентов и заказов
|
20
Makefile
20
Makefile
|
@ -1,24 +1,14 @@
|
||||||
export ROOT_DIR=$(shell dirname $(realpath $(lastword $(MAKEFILE_LIST))))
|
FILE = $(TRAVIS_BUILD_DIR)/VERSION
|
||||||
|
|
||||||
VERSION = `cat $(FILE)`
|
VERSION = `cat $(FILE)`
|
||||||
ARCHIVE_NAME = '/tmp/retailcrm-retailcrm-'$(VERSION)'.zip'
|
ARCHIVE_NAME = '/tmp/retailcrm-retailcrm-'$(VERSION)'.zip'
|
||||||
MAGE_ROOT=$(shell dirname $(realpath $(lastword $(MAKEFILE_LIST))))/../magento2
|
|
||||||
|
|
||||||
.PHONY: build_archive delete_archive
|
all: build_archive send_to_ftp delete_archive
|
||||||
|
|
||||||
build_archive:
|
build_archive:
|
||||||
cd src; zip -r $(ARCHIVE_NAME) ./*
|
cd src; zip -r $(ARCHIVE_NAME) ./*
|
||||||
|
|
||||||
|
send_to_ftp:
|
||||||
|
curl -T $(ARCHIVE_NAME) -u $(FTP_USER):$(FTP_PASSWORD) ftp://$(FTP_HOST)
|
||||||
|
|
||||||
delete_archive:
|
delete_archive:
|
||||||
rm -f $(ARCHIVE_NAME)
|
rm -f $(ARCHIVE_NAME)
|
||||||
|
|
||||||
test:
|
|
||||||
mkdir coverage
|
|
||||||
|
|
||||||
php $(MAGE_ROOT)/vendor/phpunit/phpunit/phpunit -c $(MAGE_ROOT)/dev/tests/unit/phpunit.xml.dist $(MAGE_ROOT)/app/code/Retailcrm/Retailcrm/Test/Unit
|
|
||||||
|
|
||||||
before_script:
|
|
||||||
bash bin/install.sh
|
|
||||||
|
|
||||||
coverage:
|
|
||||||
wget https://phar.phpunit.de/phpcov-2.0.2.phar && php phpcov-2.0.2.phar merge coverage/ --clover coverage.xml
|
|
16
README.md
16
README.md
|
@ -1,21 +1,17 @@
|
||||||
[](http://unmaintained.tech/)
|
[](https://travis-ci.org/retailcrm/magento-module)
|
||||||
[](https://github.com/retailcrm/magento-module/actions)
|
[](https://github.com/retailcrm/magento-module/releases)
|
||||||
[](https://codecov.io/gh/retailcrm/magento-module)
|
|
||||||
[](https://github.com/retailcrm/magento-module/)
|
|
||||||
[](https://php.net/)
|
[](https://php.net/)
|
||||||
|
|
||||||
DEPRECATED Magento module
|
Magento module
|
||||||
==============
|
==============
|
||||||
|
|
||||||
**The module is deprecated and no longer supported**
|
Magento 2 module for interaction with [retailCRM](http://www.retailcrm.ru).
|
||||||
|
|
||||||
Magento 2 module for interaction with [RetailCRM](http://www.retailcrm.ru) ([Documentation](https://docs.retailcrm.pro/Users/Integration/SiteModules/Magento) page)
|
|
||||||
|
|
||||||
Module allows:
|
Module allows:
|
||||||
|
|
||||||
* Exchange the orders data with RetailCRM
|
* Exchange the orders data with retailCRM
|
||||||
* Configure relations between dictionaries of retailCRM and Magento (statuses, payments, delivery types and etc)
|
* Configure relations between dictionaries of retailCRM and Magento (statuses, payments, delivery types and etc)
|
||||||
* Generate [ICML](http://www.retailcrm.ru/docs/Developers/ICML) (Intaro Markup Language) export file for catalog loading by RetailCRM
|
* Generate [ICML](http://www.retailcrm.ru/docs/Developers/ICML) (Intaro Markup Language) export file for catalog loading by retailCRM
|
||||||
|
|
||||||
## ICML
|
## ICML
|
||||||
|
|
||||||
|
|
25
README.ru.md
25
README.ru.md
|
@ -1,18 +1,27 @@
|
||||||
DEPRECATED Magento module
|
Magento module
|
||||||
|
|
||||||
**Модуль устарел и больше не поддерживается**
|
Модуль Magento 2 для интеграции с [retailCRM](http://www.retailcrm.ru).
|
||||||
|
|
||||||
Модуль Magento 2 для интеграции с [RetailCRM](http://www.retailcrm.ru) ([Документация](https://docs.retailcrm.ru/Users/Integration/SiteModules/Magento))
|
|
||||||
|
|
||||||
Модуль позволяет:
|
Модуль позволяет:
|
||||||
|
|
||||||
* Производить обмен заказами с RetailCRM
|
* Производить обмен заказами с retailCRM
|
||||||
* Настроить соответствие справочников RetailCRM и Magento (статусы, оплаты, типы доставки и т.д.)
|
* Настроить соответствие справочников retailCRM и Magento (статусы, оплаты, типы доставки и т.д.)
|
||||||
* Создать [ICML](http://www.retailcrm.ru/docs/Developers/ICML) (Intaro Markup Language) для загрузки каталога товаров в RetailCRM
|
* Создать [ICML](http://www.retailcrm.ru/docs/Developers/ICML) (Intaro Markup Language) для загрузки каталога товаров в retailCRM
|
||||||
|
|
||||||
|
### ICML
|
||||||
|
|
||||||
|
По умолчанию ICML-файл генерируется модулем каждые 4 часа. Вы можете найти файл в корневой директории с именем «retailcrm_{{shop_code}}.xml". Например, http://example.org/retailcrm_default.xml
|
||||||
|
|
||||||
|
### Ручная установка
|
||||||
|
|
||||||
|
1) Находясь в корневой директории проекта выполните команду:
|
||||||
|
|
||||||
|
* Настроить соответствие справочников retailCRM и Magento (статусы, оплаты, типы доставки и т.д.)
|
||||||
|
* Создать [ICML] (http://www.retailcrm.ru/docs/Developers/ICML) (Intaro Markup Language) для загрузки каталога товаров в RetailCRM
|
||||||
|
|
||||||
## ICML
|
## ICML
|
||||||
|
|
||||||
По умолчанию ICML-файл генерируется модулем каждые 4 часа. Вы можете найти файл в корневой папке с именем «retailcrm_{{shop_code}}.xml". Например, http://example.ru/retailcrm_default.xml
|
По умолчанию ICML-файл генерируется модулем каждые 4 часа. Вы можете найти файл в корневой папке с именем «retailcrm_{{shop_code}}.xml". Например, http://retailcrm.ru/retailcrm_default.xml
|
||||||
|
|
||||||
## Ручная установка
|
## Ручная установка
|
||||||
|
|
||||||
|
|
2
VERSION
2
VERSION
|
@ -1 +1 @@
|
||||||
2.5.2
|
2.5.0
|
|
@ -1,13 +1,13 @@
|
||||||
#!/usr/bin/env bash
|
#!/usr/bin/env bash
|
||||||
|
|
||||||
if [ -z $ROOT_DIR ]; then
|
if [ -z $TRAVIS_BUILD_DIR ]; then
|
||||||
exit 0;
|
exit 0;
|
||||||
fi
|
fi
|
||||||
|
|
||||||
MAGE_ROOT=$ROOT_DIR/../magento2
|
MAGE_ROOT=$TRAVIS_BUILD_DIR/../magento2
|
||||||
|
|
||||||
create_db() {
|
create_db() {
|
||||||
mysqladmin create "magento2_test" --user="root" --password="root"
|
mysqladmin create $DB_NAME --user="$DB_USER" --password="$DB_PASS"
|
||||||
}
|
}
|
||||||
|
|
||||||
magento_clone() {
|
magento_clone() {
|
||||||
|
@ -15,38 +15,22 @@ magento_clone() {
|
||||||
git clone https://github.com/magento/magento2
|
git clone https://github.com/magento/magento2
|
||||||
cd magento2
|
cd magento2
|
||||||
git checkout $BRANCH
|
git checkout $BRANCH
|
||||||
|
composer install
|
||||||
touch auth.json
|
|
||||||
echo '
|
|
||||||
{
|
|
||||||
"http-basic": {
|
|
||||||
"repo.magento.com": {
|
|
||||||
"username": "<public-key>",
|
|
||||||
"password": "<private-key>"
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
' > auth.json
|
|
||||||
|
|
||||||
sudo sed -e "s?<public-key>?$PUBLIC_KEY?g" --in-place auth.json
|
|
||||||
sudo sed -e "s?<private-key>?$PRIVATE_KEY?g" --in-place auth.json
|
|
||||||
|
|
||||||
composer install --no-interaction --prefer-dist
|
|
||||||
composer require retailcrm/api-client-php
|
composer require retailcrm/api-client-php
|
||||||
}
|
}
|
||||||
|
|
||||||
magento_install() {
|
magento_install() {
|
||||||
cd $MAGE_ROOT
|
cd $MAGE_ROOT
|
||||||
|
|
||||||
php bin/magento setup:install \
|
php bin/magento setup:install \
|
||||||
--db-host="localhost" \
|
--db-host="$DB_HOST" \
|
||||||
--db-name="magento2_test" \
|
--db-name="$DB_NAME" \
|
||||||
--db-user="root" \
|
--db-user="$DB_USER" \
|
||||||
--db-password="root" \
|
--admin-firstname="$ADMIN_FIRSTNAME" \
|
||||||
--admin-firstname="admin_firstname" \
|
--admin-lastname="$ADMIN_LASTNAME" \
|
||||||
--admin-lastname="admin_lastname" \
|
--admin-email="$ADMIN_EMAIL" \
|
||||||
--admin-email="example@email.com" \
|
--admin-user="$ADMIN_USER" \
|
||||||
--admin-user="admin" \
|
--admin-password="$ADMIN_PASS" \
|
||||||
--admin-password="admin123" \
|
|
||||||
--language="en_US" \
|
--language="en_US" \
|
||||||
--currency="USD" \
|
--currency="USD" \
|
||||||
--timezone="Europe/Moscow"
|
--timezone="Europe/Moscow"
|
||||||
|
@ -55,7 +39,7 @@ magento_install() {
|
||||||
module_install() {
|
module_install() {
|
||||||
cd $MAGE_ROOT
|
cd $MAGE_ROOT
|
||||||
mkdir -p app/code/Retailcrm/Retailcrm
|
mkdir -p app/code/Retailcrm/Retailcrm
|
||||||
cp -R $ROOT_DIR/src/* app/code/Retailcrm/Retailcrm
|
cp -R $TRAVIS_BUILD_DIR/src/* app/code/Retailcrm/Retailcrm
|
||||||
|
|
||||||
php bin/magento module:enable Retailcrm_Retailcrm
|
php bin/magento module:enable Retailcrm_Retailcrm
|
||||||
php bin/magento setup:upgrade
|
php bin/magento setup:upgrade
|
||||||
|
|
9
bin/script.sh
Normal file
9
bin/script.sh
Normal file
|
@ -0,0 +1,9 @@
|
||||||
|
#!/usr/bin/env bash
|
||||||
|
|
||||||
|
if [ -z $TRAVIS_BUILD_DIR ]; then
|
||||||
|
exit 0;
|
||||||
|
fi
|
||||||
|
|
||||||
|
MAGE_ROOT=$TRAVIS_BUILD_DIR/../magento2
|
||||||
|
cd $MAGE_ROOT
|
||||||
|
php vendor/phpunit/phpunit/phpunit -c dev/tests/unit/phpunit.xml.dist app/code/Retailcrm/Retailcrm/Test/Unit
|
|
@ -81,8 +81,13 @@ class Payment extends \Magento\Config\Block\System\Config\Form\Fieldset
|
||||||
$html .= $this->_getHeaderHtml($element);
|
$html .= $this->_getHeaderHtml($element);
|
||||||
|
|
||||||
if ($this->client->isConfigured()) {
|
if ($this->client->isConfigured()) {
|
||||||
$paymentMethods = $this->paymentConfig->getActiveMethods();
|
$manager = \Magento\Framework\App\ObjectManager::getInstance();
|
||||||
foreach ($paymentMethods as $code => $payment) {
|
$paymentMethodListInterface = $manager->get(\Magento\Payment\Api\PaymentMethodListInterface::class);
|
||||||
|
$storeManagerInterface = $manager->get('Magento\Store\Model\StoreManagerInterface');
|
||||||
|
$storeId = $storeManagerInterface->getStore()->getId();
|
||||||
|
$paymentMethodList = $paymentMethodListInterface->getActiveList($storeId);
|
||||||
|
|
||||||
|
foreach ($paymentMethodList as $code => $payment) {
|
||||||
$html .= $this->_getFieldHtml($element, $payment);
|
$html .= $this->_getFieldHtml($element, $payment);
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
|
@ -116,7 +121,7 @@ class Payment extends \Magento\Config\Block\System\Config\Form\Fieldset
|
||||||
return $defaultValues;
|
return $defaultValues;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (isset($response['paymentTypes']) && $response->isSuccessful()) {
|
if ($response->isSuccessful()) {
|
||||||
$paymentsTypes = $response['paymentTypes'];
|
$paymentsTypes = $response['paymentTypes'];
|
||||||
} else {
|
} else {
|
||||||
return $defaultValues;
|
return $defaultValues;
|
||||||
|
|
|
@ -1,95 +0,0 @@
|
||||||
<?php
|
|
||||||
|
|
||||||
namespace Retailcrm\Retailcrm\Block\Adminhtml\System\Config\Form\Fieldset;
|
|
||||||
|
|
||||||
class PaymentList extends \Magento\Config\Block\System\Config\Form\Field\FieldArray\AbstractFieldArray
|
|
||||||
{
|
|
||||||
/**
|
|
||||||
* @var $_paymentCms \Retailcrm\Retailcrm\Model\Config\Backend\PaymentCms
|
|
||||||
*/
|
|
||||||
protected $_paymentCms;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @var $_paymentCrm \Retailcrm\Retailcrm\Model\Config\Backend\PaymentCrm
|
|
||||||
*/
|
|
||||||
protected $_paymentCrm;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @return \Magento\Framework\View\Element\BlockInterface
|
|
||||||
* @throws \Magento\Framework\Exception\LocalizedException
|
|
||||||
*/
|
|
||||||
protected function _getPaymentCmsRenderer()
|
|
||||||
{
|
|
||||||
if (!$this->_paymentCms) {
|
|
||||||
$this->_paymentCms = $this->getLayout()->createBlock(
|
|
||||||
'\Retailcrm\Retailcrm\Model\Config\Backend\PaymentCms',
|
|
||||||
'',
|
|
||||||
['data' => ['is_render_to_js_template' => true]]
|
|
||||||
);
|
|
||||||
}
|
|
||||||
|
|
||||||
return $this->_paymentCms;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @return \Magento\Framework\View\Element\BlockInterface
|
|
||||||
* @throws \Magento\Framework\Exception\LocalizedException
|
|
||||||
*/
|
|
||||||
protected function _getPaymentCrmRenderer()
|
|
||||||
{
|
|
||||||
if (!$this->_paymentCrm) {
|
|
||||||
$this->_paymentCrm = $this->getLayout()->createBlock(
|
|
||||||
'\Retailcrm\Retailcrm\Model\Config\Backend\PaymentCrm',
|
|
||||||
'',
|
|
||||||
['data' => ['is_render_to_js_template' => true]]
|
|
||||||
);
|
|
||||||
}
|
|
||||||
|
|
||||||
return $this->_paymentCrm;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @throws \Magento\Framework\Exception\LocalizedException
|
|
||||||
*/
|
|
||||||
protected function _prepareToRender()
|
|
||||||
{
|
|
||||||
$this->addColumn(
|
|
||||||
'payment_cms',
|
|
||||||
[
|
|
||||||
'label' => __('CMS'),
|
|
||||||
'renderer' => $this->_getPaymentCmsRenderer()
|
|
||||||
]
|
|
||||||
);
|
|
||||||
|
|
||||||
$this->addColumn(
|
|
||||||
'payment_crm',
|
|
||||||
[
|
|
||||||
'label' => __('CRM'),
|
|
||||||
'renderer' => $this->_getPaymentCrmRenderer()
|
|
||||||
]
|
|
||||||
);
|
|
||||||
|
|
||||||
$this->_addAfter = false;
|
|
||||||
$this->_addButtonLabel = __('Add');
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
*
|
|
||||||
* @param \Magento\Framework\DataObject $row
|
|
||||||
* @throws \Magento\Framework\Exception\LocalizedException
|
|
||||||
* @return void
|
|
||||||
*/
|
|
||||||
protected function _prepareArrayRow(\Magento\Framework\DataObject $row)
|
|
||||||
{
|
|
||||||
$options = [];
|
|
||||||
$customAttribute = $row->getData('payment_cms');
|
|
||||||
$key = 'option_' . $this->_getPaymentCmsRenderer()->calcOptionHash($customAttribute);
|
|
||||||
$options[$key] = 'selected="selected"';
|
|
||||||
|
|
||||||
$customAttribute = $row->getData('payment_crm');
|
|
||||||
$key = 'option_' . $this->_getPaymentCrmRenderer()->calcOptionHash($customAttribute);
|
|
||||||
$options[$key] = 'selected="selected"';
|
|
||||||
|
|
||||||
$row->setData('option_extra_attrs', $options);
|
|
||||||
}
|
|
||||||
}
|
|
|
@ -117,17 +117,13 @@ class Shipping extends \Magento\Config\Block\System\Config\Form\Fieldset
|
||||||
|
|
||||||
$values = [];
|
$values = [];
|
||||||
|
|
||||||
try {
|
$response = $this->client->deliveryTypesList();
|
||||||
$response = $this->client->deliveryTypesList();
|
|
||||||
} catch (\Exception $exception) {
|
|
||||||
return $defaultValues;
|
|
||||||
}
|
|
||||||
|
|
||||||
if ($response === false) {
|
if ($response === false) {
|
||||||
return $defaultValues;
|
return $defaultValues;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (isset($response['deliveryTypes']) && $response->isSuccessful()) {
|
if ($response->isSuccessful()) {
|
||||||
$deliveryTypes = $response['deliveryTypes'];
|
$deliveryTypes = $response['deliveryTypes'];
|
||||||
} else {
|
} else {
|
||||||
return $defaultValues;
|
return $defaultValues;
|
||||||
|
|
|
@ -1,95 +0,0 @@
|
||||||
<?php
|
|
||||||
|
|
||||||
namespace Retailcrm\Retailcrm\Block\Adminhtml\System\Config\Form\Fieldset;
|
|
||||||
|
|
||||||
class ShippingList extends \Magento\Config\Block\System\Config\Form\Field\FieldArray\AbstractFieldArray
|
|
||||||
{
|
|
||||||
/**
|
|
||||||
* @var $_shippingCms \Retailcrm\Retailcrm\Model\Config\Backend\ShippingCms
|
|
||||||
*/
|
|
||||||
protected $_shippingCms;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @var $_shippingCrm \Retailcrm\Retailcrm\Model\Config\Backend\ShippingCrm
|
|
||||||
*/
|
|
||||||
protected $_shippingCrm;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @return \Magento\Framework\View\Element\BlockInterface
|
|
||||||
* @throws \Magento\Framework\Exception\LocalizedException
|
|
||||||
*/
|
|
||||||
protected function _getShippingCmsRenderer()
|
|
||||||
{
|
|
||||||
if (!$this->_shippingCms) {
|
|
||||||
$this->_shippingCms = $this->getLayout()->createBlock(
|
|
||||||
'\Retailcrm\Retailcrm\Model\Config\Backend\ShippingCms',
|
|
||||||
'',
|
|
||||||
['data' => ['is_render_to_js_template' => true]]
|
|
||||||
);
|
|
||||||
}
|
|
||||||
|
|
||||||
return $this->_shippingCms;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @return \Magento\Framework\View\Element\BlockInterface
|
|
||||||
* @throws \Magento\Framework\Exception\LocalizedException
|
|
||||||
*/
|
|
||||||
protected function _getShippingCrmRenderer()
|
|
||||||
{
|
|
||||||
if (!$this->_shippingCrm) {
|
|
||||||
$this->_shippingCrm = $this->getLayout()->createBlock(
|
|
||||||
'\Retailcrm\Retailcrm\Model\Config\Backend\ShippingCrm',
|
|
||||||
'',
|
|
||||||
['data' => ['is_render_to_js_template' => true]]
|
|
||||||
);
|
|
||||||
}
|
|
||||||
|
|
||||||
return $this->_shippingCrm;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @throws \Magento\Framework\Exception\LocalizedException
|
|
||||||
*/
|
|
||||||
protected function _prepareToRender()
|
|
||||||
{
|
|
||||||
$this->addColumn(
|
|
||||||
'shipping_cms',
|
|
||||||
[
|
|
||||||
'label' => __('CMS'),
|
|
||||||
'renderer' => $this->_getShippingCmsRenderer()
|
|
||||||
]
|
|
||||||
);
|
|
||||||
|
|
||||||
$this->addColumn(
|
|
||||||
'shipping_crm',
|
|
||||||
[
|
|
||||||
'label' => __('CRM'),
|
|
||||||
'renderer' => $this->_getShippingCrmRenderer()
|
|
||||||
]
|
|
||||||
);
|
|
||||||
|
|
||||||
$this->_addAfter = false;
|
|
||||||
$this->_addButtonLabel = __('Add');
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
*
|
|
||||||
* @param \Magento\Framework\DataObject $row
|
|
||||||
* @throws \Magento\Framework\Exception\LocalizedException
|
|
||||||
* @return void
|
|
||||||
*/
|
|
||||||
protected function _prepareArrayRow(\Magento\Framework\DataObject $row)
|
|
||||||
{
|
|
||||||
$options = [];
|
|
||||||
$customAttribute = $row->getData('shipping_cms');
|
|
||||||
$key = 'option_' . $this->_getShippingCmsRenderer()->calcOptionHash($customAttribute);
|
|
||||||
$options[$key] = 'selected="selected"';
|
|
||||||
|
|
||||||
$customAttribute = $row->getData('shipping_crm');
|
|
||||||
$key = 'option_' . $this->_getShippingCrmRenderer()->calcOptionHash($customAttribute);
|
|
||||||
$options[$key] = 'selected="selected"';
|
|
||||||
|
|
||||||
$row->setData('option_extra_attrs', $options);
|
|
||||||
}
|
|
||||||
}
|
|
|
@ -109,17 +109,13 @@ class Site extends \Magento\Config\Block\System\Config\Form\Fieldset
|
||||||
|
|
||||||
$values = [];
|
$values = [];
|
||||||
|
|
||||||
try {
|
$response = $this->client->sitesList();
|
||||||
$response = $this->client->sitesList();
|
|
||||||
} catch (\Exception $exception) {
|
|
||||||
return $defaultValues;
|
|
||||||
}
|
|
||||||
|
|
||||||
if ($response === false) {
|
if ($response === false) {
|
||||||
return $defaultValues;
|
return $defaultValues;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (isset($response['sites']) && $response->isSuccessful()) {
|
if ($response->isSuccessful()) {
|
||||||
$sites = $response['sites'];
|
$sites = $response['sites'];
|
||||||
} else {
|
} else {
|
||||||
return $defaultValues;
|
return $defaultValues;
|
||||||
|
|
|
@ -115,17 +115,13 @@ class Sites extends \Magento\Config\Block\System\Config\Form\Fieldset
|
||||||
|
|
||||||
$values = [];
|
$values = [];
|
||||||
|
|
||||||
try {
|
$response = $this->client->sitesList();
|
||||||
$response = $this->client->sitesList();
|
|
||||||
} catch (\Exception $exception) {
|
|
||||||
return $defaultValues;
|
|
||||||
}
|
|
||||||
|
|
||||||
if ($response === false) {
|
if ($response === false) {
|
||||||
return $defaultValues;
|
return $defaultValues;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (isset($response['sites']) && $response->isSuccessful()) {
|
if ($response->isSuccessful()) {
|
||||||
$sites = $response['sites'];
|
$sites = $response['sites'];
|
||||||
} else {
|
} else {
|
||||||
return $defaultValues;
|
return $defaultValues;
|
||||||
|
|
|
@ -111,17 +111,13 @@ class Status extends \Magento\Config\Block\System\Config\Form\Fieldset
|
||||||
|
|
||||||
$values = [];
|
$values = [];
|
||||||
|
|
||||||
try {
|
$response = $this->client->statusesList();
|
||||||
$response = $this->client->statusesList();
|
|
||||||
} catch (\Exception $exception) {
|
|
||||||
return $defaultValues;
|
|
||||||
}
|
|
||||||
|
|
||||||
if ($response === false) {
|
if ($response === false) {
|
||||||
return $defaultValues;
|
return $defaultValues;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (isset($response['statuses']) && $response->isSuccessful()) {
|
if ($response->isSuccessful()) {
|
||||||
$statuses = $response['statuses'];
|
$statuses = $response['statuses'];
|
||||||
} else {
|
} else {
|
||||||
return $defaultValues;
|
return $defaultValues;
|
||||||
|
|
|
@ -1,95 +0,0 @@
|
||||||
<?php
|
|
||||||
|
|
||||||
namespace Retailcrm\Retailcrm\Block\Adminhtml\System\Config\Form\Fieldset;
|
|
||||||
|
|
||||||
class StatusList extends \Magento\Config\Block\System\Config\Form\Field\FieldArray\AbstractFieldArray
|
|
||||||
{
|
|
||||||
/**
|
|
||||||
* @var $_statusCms \Retailcrm\Retailcrm\Model\Config\Backend\StatusCms
|
|
||||||
*/
|
|
||||||
protected $_statusCms;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @var $_statusCrm \Retailcrm\Retailcrm\Model\Config\Backend\StatusCrm
|
|
||||||
*/
|
|
||||||
protected $_statusCrm;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @return \Magento\Framework\View\Element\BlockInterface
|
|
||||||
* @throws \Magento\Framework\Exception\LocalizedException
|
|
||||||
*/
|
|
||||||
protected function _getStatusCmsRenderer()
|
|
||||||
{
|
|
||||||
if (!$this->_statusCms) {
|
|
||||||
$this->_statusCms = $this->getLayout()->createBlock(
|
|
||||||
'\Retailcrm\Retailcrm\Model\Config\Backend\StatusCms',
|
|
||||||
'',
|
|
||||||
['data' => ['is_render_to_js_template' => true]]
|
|
||||||
);
|
|
||||||
}
|
|
||||||
|
|
||||||
return $this->_statusCms;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @return \Magento\Framework\View\Element\BlockInterface
|
|
||||||
* @throws \Magento\Framework\Exception\LocalizedException
|
|
||||||
*/
|
|
||||||
protected function _getStatusCrmRenderer()
|
|
||||||
{
|
|
||||||
if (!$this->_statusCrm) {
|
|
||||||
$this->_statusCrm = $this->getLayout()->createBlock(
|
|
||||||
'\Retailcrm\Retailcrm\Model\Config\Backend\StatusCrm',
|
|
||||||
'',
|
|
||||||
['data' => ['is_render_to_js_template' => true]]
|
|
||||||
);
|
|
||||||
}
|
|
||||||
|
|
||||||
return $this->_statusCrm;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @throws \Magento\Framework\Exception\LocalizedException
|
|
||||||
*/
|
|
||||||
protected function _prepareToRender()
|
|
||||||
{
|
|
||||||
$this->addColumn(
|
|
||||||
'status_cms',
|
|
||||||
[
|
|
||||||
'label' => __('CMS'),
|
|
||||||
'renderer' => $this->_getStatusCmsRenderer()
|
|
||||||
]
|
|
||||||
);
|
|
||||||
|
|
||||||
$this->addColumn(
|
|
||||||
'status_crm',
|
|
||||||
[
|
|
||||||
'label' => __('CRM'),
|
|
||||||
'renderer' => $this->_getStatusCrmRenderer()
|
|
||||||
]
|
|
||||||
);
|
|
||||||
|
|
||||||
$this->_addAfter = false;
|
|
||||||
$this->_addButtonLabel = __('Add');
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
*
|
|
||||||
* @param \Magento\Framework\DataObject $row
|
|
||||||
* @throws \Magento\Framework\Exception\LocalizedException
|
|
||||||
* @return void
|
|
||||||
*/
|
|
||||||
protected function _prepareArrayRow(\Magento\Framework\DataObject $row)
|
|
||||||
{
|
|
||||||
$options = [];
|
|
||||||
$customAttribute = $row->getData('status_cms');
|
|
||||||
$key = 'option_' . $this->_getStatusCmsRenderer()->calcOptionHash($customAttribute);
|
|
||||||
$options[$key] = 'selected="selected"';
|
|
||||||
|
|
||||||
$customAttribute = $row->getData('status_crm');
|
|
||||||
$key = 'option_' . $this->_getStatusCrmRenderer()->calcOptionHash($customAttribute);
|
|
||||||
$options[$key] = 'selected="selected"';
|
|
||||||
|
|
||||||
$row->setData('option_extra_attrs', $options);
|
|
||||||
}
|
|
||||||
}
|
|
|
@ -44,7 +44,7 @@ class CustomersExport extends Command
|
||||||
protected function configure()
|
protected function configure()
|
||||||
{
|
{
|
||||||
$this->setName('retailcrm:customers:export')
|
$this->setName('retailcrm:customers:export')
|
||||||
->setDescription('Upload archive customers to RetailCRM from Magento')
|
->setDescription('Upload archive customers to retailCRM from Magento')
|
||||||
->addArgument('from', InputArgument::OPTIONAL, 'Beginning order number')
|
->addArgument('from', InputArgument::OPTIONAL, 'Beginning order number')
|
||||||
->addArgument('to', InputArgument::OPTIONAL, 'End order number');
|
->addArgument('to', InputArgument::OPTIONAL, 'End order number');
|
||||||
|
|
||||||
|
@ -52,7 +52,7 @@ class CustomersExport extends Command
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Upload customers to RetailCRM
|
* Upload customers to retailCRM
|
||||||
*
|
*
|
||||||
* @param InputInterface $input
|
* @param InputInterface $input
|
||||||
* @param OutputInterface $output
|
* @param OutputInterface $output
|
||||||
|
|
|
@ -37,7 +37,7 @@ class OrdersExport extends Command
|
||||||
protected function configure()
|
protected function configure()
|
||||||
{
|
{
|
||||||
$this->setName('retailcrm:orders:export')
|
$this->setName('retailcrm:orders:export')
|
||||||
->setDescription('Upload archive orders to RetailCRM from Magento')
|
->setDescription('Upload archive orders to retailCRM from Magento')
|
||||||
->addArgument('from', InputArgument::OPTIONAL, 'Beginning order number')
|
->addArgument('from', InputArgument::OPTIONAL, 'Beginning order number')
|
||||||
->addArgument('to', InputArgument::OPTIONAL, 'End order number');
|
->addArgument('to', InputArgument::OPTIONAL, 'End order number');
|
||||||
|
|
||||||
|
@ -45,7 +45,7 @@ class OrdersExport extends Command
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Upload orders to RetailCRM
|
* Upload orders to retailCRM
|
||||||
*
|
*
|
||||||
* @param InputInterface $input
|
* @param InputInterface $input
|
||||||
* @param OutputInterface $output
|
* @param OutputInterface $output
|
||||||
|
|
|
@ -206,63 +206,4 @@ class Data extends AbstractHelper
|
||||||
|
|
||||||
return $haystack;
|
return $haystack;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* @return mixed
|
|
||||||
*/
|
|
||||||
public function getConfigPayments()
|
|
||||||
{
|
|
||||||
$json = $this->scopeConfig->getValue('retailcrm/paymentList/paymentList');
|
|
||||||
$List = $this->getConfigJsonUnserialize($json);
|
|
||||||
foreach ($List as $code => $el) {
|
|
||||||
$payments[$el['payment_cms']] = $el['payment_crm'];
|
|
||||||
}
|
|
||||||
|
|
||||||
return $payments;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @return mixed
|
|
||||||
*/
|
|
||||||
public function getCongigShipping()
|
|
||||||
{
|
|
||||||
$json = $this->scopeConfig->getValue('retailcrm/shippingList/shippingList');
|
|
||||||
$shippingList = $this->getConfigJsonUnserialize($json);
|
|
||||||
foreach ($shippingList as $code => $el) {
|
|
||||||
$shippings[$el['shipping_cms']] = $el['shipping_crm'];
|
|
||||||
}
|
|
||||||
|
|
||||||
return $shippings;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @return mixed
|
|
||||||
*/
|
|
||||||
public function getCongigStatus()
|
|
||||||
{
|
|
||||||
$json = $this->scopeConfig->getValue('retailcrm/statusList/statusList');
|
|
||||||
$List = $this->getConfigJsonUnserialize($json);
|
|
||||||
foreach ($List as $code => $el) {
|
|
||||||
$statusList[$el['status_cms']] = $el['status_crm'];
|
|
||||||
}
|
|
||||||
|
|
||||||
return $statusList;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @param $json
|
|
||||||
*
|
|
||||||
* @return mixed
|
|
||||||
*/
|
|
||||||
public function getConfigJsonUnserialize($json)
|
|
||||||
{
|
|
||||||
if (class_exists(\Magento\Framework\Serialize\Serializer\Json::class)) {
|
|
||||||
$objectManager = \Magento\Framework\App\ObjectManager::getInstance();
|
|
||||||
$serializer = $objectManager->create(\Magento\Framework\Serialize\Serializer\Json::class);
|
|
||||||
return $serializer->unserialize($json);
|
|
||||||
} else {
|
|
||||||
return json_decode($json);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -82,7 +82,7 @@ class ApiUrl extends \Magento\Framework\App\Config\Value
|
||||||
} elseif (!$response->isSuccessful() && $response['errorMsg'] == $api->getErrorText('errorApiKey')) {
|
} elseif (!$response->isSuccessful() && $response['errorMsg'] == $api->getErrorText('errorApiKey')) {
|
||||||
throw new \Magento\Framework\Exception\ValidatorException(__('Incorrect API key'));
|
throw new \Magento\Framework\Exception\ValidatorException(__('Incorrect API key'));
|
||||||
} elseif (isset($response['errorMsg']) && $response['errorMsg'] == $api->getErrorText('errorAccount')) {
|
} elseif (isset($response['errorMsg']) && $response['errorMsg'] == $api->getErrorText('errorAccount')) {
|
||||||
throw new \Magento\Framework\Exception\ValidatorException(__('Incorrect URL of RetailCRM'));
|
throw new \Magento\Framework\Exception\ValidatorException(__('Incorrect URL of retailCRM'));
|
||||||
}
|
}
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
|
|
|
@ -82,7 +82,7 @@ class ApiVersion extends \Magento\Framework\App\Config\Value
|
||||||
if ($response->isSuccessful()) {
|
if ($response->isSuccessful()) {
|
||||||
$availableVersions = $response['versions'];
|
$availableVersions = $response['versions'];
|
||||||
} else {
|
} else {
|
||||||
throw new \Magento\Framework\Exception\ValidatorException(__('Incorrect URL of RetailCRM or API key'));
|
throw new \Magento\Framework\Exception\ValidatorException(__('Incorrect URL of retailCRM or API key'));
|
||||||
}
|
}
|
||||||
|
|
||||||
if (isset($availableVersions)) {
|
if (isset($availableVersions)) {
|
||||||
|
|
|
@ -1,71 +0,0 @@
|
||||||
<?php
|
|
||||||
|
|
||||||
namespace Retailcrm\Retailcrm\Model\Config\Backend;
|
|
||||||
|
|
||||||
class PaymentCms extends \Magento\Framework\View\Element\Html\Select
|
|
||||||
{
|
|
||||||
/**
|
|
||||||
* @var \Magento\Payment\Model\Config
|
|
||||||
*/
|
|
||||||
private $paymentConfig;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @var \Retailcrm\Retailcrm\Model\Logger\Logger
|
|
||||||
*/
|
|
||||||
private $logger;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* PaymentCms constructor.
|
|
||||||
*
|
|
||||||
* @param \Magento\Framework\View\Element\Context $context
|
|
||||||
* @param \Magento\Payment\Model\Config $paymentConfig
|
|
||||||
* @param array $data
|
|
||||||
*/
|
|
||||||
public function __construct(
|
|
||||||
\Magento\Framework\View\Element\Context $context,
|
|
||||||
\Magento\Payment\Model\Config $paymentConfig,
|
|
||||||
\Retailcrm\Retailcrm\Model\Logger\Logger $logger,
|
|
||||||
array $data = []
|
|
||||||
) {
|
|
||||||
parent::__construct($context, $data);
|
|
||||||
|
|
||||||
$this->paymentConfig = $paymentConfig;
|
|
||||||
$this->logger = $logger;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @param string $value
|
|
||||||
* @return Magently\Tutorial\Block\Adminhtml\Form\Field\Activation
|
|
||||||
*/
|
|
||||||
public function setInputName($value)
|
|
||||||
{
|
|
||||||
return $this->setName($value);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Parse to html.
|
|
||||||
*
|
|
||||||
* @return mixed
|
|
||||||
*/
|
|
||||||
public function _toHtml()
|
|
||||||
{
|
|
||||||
if (!$this->getOptions()) {
|
|
||||||
$paymentMethods = array();
|
|
||||||
|
|
||||||
try {
|
|
||||||
$paymentMethods = $this->paymentConfig->getActiveMethods();
|
|
||||||
} catch (\Exception $exception) {
|
|
||||||
$this->logger->writeRow($exception->getMessage());
|
|
||||||
}
|
|
||||||
|
|
||||||
$this->addOption( 'null', "not selected");
|
|
||||||
if ($paymentMethods) {
|
|
||||||
foreach ($paymentMethods as $code => $payment) {
|
|
||||||
$this->addOption($payment->getCode(), $payment->getTitle());
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
return parent::_toHtml();
|
|
||||||
}
|
|
||||||
}
|
|
|
@ -1,75 +0,0 @@
|
||||||
<?php
|
|
||||||
|
|
||||||
namespace Retailcrm\Retailcrm\Model\Config\Backend;
|
|
||||||
|
|
||||||
class PaymentCrm extends \Magento\Framework\View\Element\Html\Select
|
|
||||||
{
|
|
||||||
/**
|
|
||||||
* @var \Retailcrm\Retailcrm\Helper\Proxy
|
|
||||||
*/
|
|
||||||
private $client;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @var \Retailcrm\Retailcrm\Model\Logger\Logger
|
|
||||||
*/
|
|
||||||
private $logger;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Activation constructor.
|
|
||||||
*
|
|
||||||
* @param \Magento\Framework\View\Element\Context $context
|
|
||||||
* @param array $data
|
|
||||||
*/
|
|
||||||
public function __construct(
|
|
||||||
\Magento\Framework\View\Element\Context $context,
|
|
||||||
\Retailcrm\Retailcrm\Helper\Proxy $client,
|
|
||||||
\Retailcrm\Retailcrm\Model\Logger\Logger $logger,
|
|
||||||
array $data = []
|
|
||||||
) {
|
|
||||||
parent::__construct($context, $data);
|
|
||||||
|
|
||||||
$this->client = $client;
|
|
||||||
$this->logger = $logger;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @param string $value
|
|
||||||
* @return Magently\Tutorial\Block\Adminhtml\Form\Field\Activation
|
|
||||||
*/
|
|
||||||
public function setInputName($value)
|
|
||||||
{
|
|
||||||
return $this->setName($value);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Parse to html.
|
|
||||||
*
|
|
||||||
* @return mixed
|
|
||||||
*/
|
|
||||||
public function _toHtml()
|
|
||||||
{
|
|
||||||
if (!$this->getOptions()) {
|
|
||||||
$paymentsTypes = array();
|
|
||||||
|
|
||||||
try {
|
|
||||||
$response = $this->client->paymentTypesList();
|
|
||||||
} catch (\Exception $exception) {
|
|
||||||
$this->logger->writeRow($exception->getMessage());
|
|
||||||
}
|
|
||||||
|
|
||||||
if (isset($response) && $response->isSuccessful()) {
|
|
||||||
$paymentsTypes = $response['paymentTypes'];
|
|
||||||
}
|
|
||||||
|
|
||||||
$this->addOption( 'null', "not selected");
|
|
||||||
if ($paymentsTypes) {
|
|
||||||
foreach ($paymentsTypes as $paymentsType) {
|
|
||||||
$this->addOption($paymentsType['code'], $paymentsType['name']);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
return parent::_toHtml();
|
|
||||||
}
|
|
||||||
}
|
|
|
@ -1,72 +0,0 @@
|
||||||
<?php
|
|
||||||
|
|
||||||
namespace Retailcrm\Retailcrm\Model\Config\Backend;
|
|
||||||
|
|
||||||
class ShippingCms extends \Magento\Framework\View\Element\Html\Select
|
|
||||||
{
|
|
||||||
/**
|
|
||||||
* @var \Magento\Shipping\Model\Config
|
|
||||||
*/
|
|
||||||
private $shippingConfig;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @var \Retailcrm\Retailcrm\Model\Logger\Logger
|
|
||||||
*/
|
|
||||||
private $logger;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* ShippingColumn constructor.
|
|
||||||
*
|
|
||||||
* @param \Magento\Framework\View\Element\Context $context
|
|
||||||
* @param \Magento\Shipping\Model\Config $shippingConfig
|
|
||||||
* @param array $data
|
|
||||||
*/
|
|
||||||
public function __construct(
|
|
||||||
\Magento\Framework\View\Element\Context $context,
|
|
||||||
\Magento\Shipping\Model\Config $shippingConfig,
|
|
||||||
\Retailcrm\Retailcrm\Model\Logger\Logger $logger,
|
|
||||||
array $data = []
|
|
||||||
) {
|
|
||||||
parent::__construct($context, $data);
|
|
||||||
|
|
||||||
$this->shippingConfig = $shippingConfig;
|
|
||||||
$this->logger = $logger;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @param string $value
|
|
||||||
* @return Magently\Tutorial\Block\Adminhtml\Form\Field\Activation
|
|
||||||
*/
|
|
||||||
public function setInputName($value)
|
|
||||||
{
|
|
||||||
return $this->setName($value);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Parse to html.
|
|
||||||
*
|
|
||||||
* @return mixed
|
|
||||||
*/
|
|
||||||
public function _toHtml()
|
|
||||||
{
|
|
||||||
if (!$this->getOptions()) {
|
|
||||||
$deliveryMethods = array();
|
|
||||||
|
|
||||||
try {
|
|
||||||
$deliveryMethods = $this->shippingConfig->getActiveCarriers();
|
|
||||||
} catch (\Exception $exception) {
|
|
||||||
$this->logger->writeRow($exception->getMessage());
|
|
||||||
}
|
|
||||||
|
|
||||||
$this->addOption( 'null', "not selected");
|
|
||||||
if ($deliveryMethods) {
|
|
||||||
foreach ($deliveryMethods as $code => $delivery) {
|
|
||||||
$this->addOption($delivery->getCarrierCode(), $delivery->getConfigData('title'));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
return parent::_toHtml();
|
|
||||||
}
|
|
||||||
}
|
|
|
@ -1,74 +0,0 @@
|
||||||
<?php
|
|
||||||
|
|
||||||
namespace Retailcrm\Retailcrm\Model\Config\Backend;
|
|
||||||
|
|
||||||
class ShippingCrm extends \Magento\Framework\View\Element\Html\Select
|
|
||||||
{
|
|
||||||
/**
|
|
||||||
* @var \Retailcrm\Retailcrm\Helper\Proxy
|
|
||||||
*/
|
|
||||||
private $client;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @var \Retailcrm\Retailcrm\Model\Logger\Logger
|
|
||||||
*/
|
|
||||||
private $logger;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Activation constructor.
|
|
||||||
*
|
|
||||||
* @param \Magento\Framework\View\Element\Context $context
|
|
||||||
* @param array $data
|
|
||||||
*/
|
|
||||||
public function __construct(
|
|
||||||
\Magento\Framework\View\Element\Context $context,
|
|
||||||
\Retailcrm\Retailcrm\Helper\Proxy $client,
|
|
||||||
\Retailcrm\Retailcrm\Model\Logger\Logger $logger,
|
|
||||||
array $data = []
|
|
||||||
) {
|
|
||||||
parent::__construct($context, $data);
|
|
||||||
|
|
||||||
$this->client = $client;
|
|
||||||
$this->logger = $logger;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @param string $value
|
|
||||||
* @return Magently\Tutorial\Block\Adminhtml\Form\Field\Activation
|
|
||||||
*/
|
|
||||||
public function setInputName($value)
|
|
||||||
{
|
|
||||||
return $this->setName($value);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Parse to html.
|
|
||||||
*
|
|
||||||
* @return mixed
|
|
||||||
*/
|
|
||||||
public function _toHtml()
|
|
||||||
{
|
|
||||||
if (!$this->getOptions()) {
|
|
||||||
$deliveryTypes = array();
|
|
||||||
|
|
||||||
try {
|
|
||||||
$response = $this->client->deliveryTypesList();
|
|
||||||
} catch (\Exception $exception) {
|
|
||||||
$this->logger->writeRow($exception->getMessage());
|
|
||||||
}
|
|
||||||
|
|
||||||
if (isset($response) && $response->isSuccessful()) {
|
|
||||||
$deliveryTypes = $response['deliveryTypes'];
|
|
||||||
}
|
|
||||||
|
|
||||||
$this->addOption( 'null', "not selected");
|
|
||||||
if ($deliveryTypes) {
|
|
||||||
foreach ($deliveryTypes as $deliveryType) {
|
|
||||||
$this->addOption($deliveryType['code'], $deliveryType['name']);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
return parent::_toHtml();
|
|
||||||
}
|
|
||||||
}
|
|
|
@ -1,71 +0,0 @@
|
||||||
<?php
|
|
||||||
|
|
||||||
namespace Retailcrm\Retailcrm\Model\Config\Backend;
|
|
||||||
|
|
||||||
class StatusCms extends \Magento\Framework\View\Element\Html\Select
|
|
||||||
{
|
|
||||||
/**
|
|
||||||
* @var \Magento\Sales\Model\ResourceModel\Order\Status\Collection
|
|
||||||
*/
|
|
||||||
private $statusCollection;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @var \Retailcrm\Retailcrm\Model\Logger\Logger
|
|
||||||
*/
|
|
||||||
private $logger;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* StatusCms constructor.
|
|
||||||
*
|
|
||||||
* @param \Magento\Framework\View\Element\Context $context
|
|
||||||
* @param \Magento\Sales\Model\ResourceModel\Order\Status\Collection $statusCollection
|
|
||||||
* @param array $data
|
|
||||||
*/
|
|
||||||
public function __construct(
|
|
||||||
\Magento\Framework\View\Element\Context $context,
|
|
||||||
\Magento\Sales\Model\ResourceModel\Order\Status\Collection $statusCollection,
|
|
||||||
\Retailcrm\Retailcrm\Model\Logger\Logger $logger,
|
|
||||||
array $data = []
|
|
||||||
) {
|
|
||||||
parent::__construct($context, $data);
|
|
||||||
|
|
||||||
$this->statusCollection = $statusCollection;
|
|
||||||
$this->logger = $logger;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @param string $value
|
|
||||||
* @return Magently\Tutorial\Block\Adminhtml\Form\Field\Activation
|
|
||||||
*/
|
|
||||||
public function setInputName($value)
|
|
||||||
{
|
|
||||||
return $this->setName($value);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Parse to html.
|
|
||||||
*
|
|
||||||
* @return mixed
|
|
||||||
*/
|
|
||||||
public function _toHtml()
|
|
||||||
{
|
|
||||||
if (!$this->getOptions()) {
|
|
||||||
$statuses = array();
|
|
||||||
|
|
||||||
try {
|
|
||||||
$statuses = $this->statusCollection->toOptionArray();
|
|
||||||
} catch (\Exception $exception) {
|
|
||||||
$this->logger->writeRow($exception->getMessage());
|
|
||||||
}
|
|
||||||
|
|
||||||
$this->addOption( 'null', "not selected");
|
|
||||||
if ($statuses) {
|
|
||||||
foreach ($statuses as $code => $status) {
|
|
||||||
$this->addOption( $status['value'], $status['label']);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
return parent::_toHtml();
|
|
||||||
}
|
|
||||||
}
|
|
|
@ -1,75 +0,0 @@
|
||||||
<?php
|
|
||||||
|
|
||||||
namespace Retailcrm\Retailcrm\Model\Config\Backend;
|
|
||||||
|
|
||||||
class StatusCrm extends \Magento\Framework\View\Element\Html\Select
|
|
||||||
{
|
|
||||||
/**
|
|
||||||
* @var \Retailcrm\Retailcrm\Helper\Proxy
|
|
||||||
*/
|
|
||||||
private $client;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @var \Retailcrm\Retailcrm\Model\Logger\Logger
|
|
||||||
*/
|
|
||||||
private $logger;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Activation constructor.
|
|
||||||
*
|
|
||||||
* @param \Magento\Framework\View\Element\Context $context
|
|
||||||
* @param array $data
|
|
||||||
*/
|
|
||||||
public function __construct(
|
|
||||||
\Magento\Framework\View\Element\Context $context,
|
|
||||||
\Retailcrm\Retailcrm\Helper\Proxy $client,
|
|
||||||
\Retailcrm\Retailcrm\Model\Logger\Logger $logger,
|
|
||||||
array $data = []
|
|
||||||
) {
|
|
||||||
parent::__construct($context, $data);
|
|
||||||
|
|
||||||
$this->client = $client;
|
|
||||||
$this->logger = $logger;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @param string $value
|
|
||||||
* @return Magently\Tutorial\Block\Adminhtml\Form\Field\Activation
|
|
||||||
*/
|
|
||||||
public function setInputName($value)
|
|
||||||
{
|
|
||||||
return $this->setName($value);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Parse to html.
|
|
||||||
*
|
|
||||||
* @return mixed
|
|
||||||
*/
|
|
||||||
public function _toHtml()
|
|
||||||
{
|
|
||||||
if (!$this->getOptions()) {
|
|
||||||
$statuses = array();
|
|
||||||
|
|
||||||
try {
|
|
||||||
$response = $this->client->statusesList();
|
|
||||||
} catch (\Exception $exception) {
|
|
||||||
$this->logger->writeRow($exception->getMessage());
|
|
||||||
}
|
|
||||||
|
|
||||||
if (isset($response) && $response->isSuccessful()) {
|
|
||||||
$statuses = $response['statuses'];
|
|
||||||
}
|
|
||||||
|
|
||||||
$this->addOption( 'null', "not selected");
|
|
||||||
if ($statuses) {
|
|
||||||
foreach ($statuses as $status) {
|
|
||||||
$this->addOption($status['code'], $status['name']);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
return parent::_toHtml();
|
|
||||||
}
|
|
||||||
}
|
|
|
@ -161,8 +161,8 @@ class Exchange
|
||||||
{
|
{
|
||||||
$this->logger->writeDump($order, 'doCreate');
|
$this->logger->writeDump($order, 'doCreate');
|
||||||
|
|
||||||
$payments = $this->helper->getConfigPayments();
|
$payments = $this->config->getValue('retailcrm/retailcrm_payment');
|
||||||
$shippings = $this->helper->getCongigShipping();
|
$shippings = $this->config->getValue('retailcrm/retailcrm_shipping');
|
||||||
$sites = $this->helper->getMappingSites();
|
$sites = $this->helper->getMappingSites();
|
||||||
|
|
||||||
if ($sites && in_array($order['site'], $sites)) {
|
if ($sites && in_array($order['site'], $sites)) {
|
||||||
|
@ -242,7 +242,7 @@ class Exchange
|
||||||
//add items in quote
|
//add items in quote
|
||||||
foreach ($ditems as $id =>$item) {
|
foreach ($ditems as $id =>$item) {
|
||||||
$product = $productRepository->getById($id,false, $store->getId(), false);
|
$product = $productRepository->getById($id,false, $store->getId(), false);
|
||||||
$product->setPrice($item['initialPrice']);
|
$product->setPrice($item['price_item']);
|
||||||
$quote->addProduct(
|
$quote->addProduct(
|
||||||
$product,
|
$product,
|
||||||
(int)$item['quantity']
|
(int)$item['quantity']
|
||||||
|
@ -349,8 +349,8 @@ class Exchange
|
||||||
$order = $response['order'];
|
$order = $response['order'];
|
||||||
}
|
}
|
||||||
|
|
||||||
$payments = $this->helper->getConfigPayments();
|
$payments = $this->config->getValue('retailcrm/retailcrm_payment');
|
||||||
$shippings = $this->helper->getCongigShipping();
|
$shippings = $this->config->getValue('retailcrm/retailcrm_shipping');
|
||||||
|
|
||||||
$region = $this->regionFactory->create();
|
$region = $this->regionFactory->create();
|
||||||
$sites = $this->helper->getMappingSites();
|
$sites = $this->helper->getMappingSites();
|
||||||
|
@ -411,7 +411,7 @@ class Exchange
|
||||||
//add items in quote
|
//add items in quote
|
||||||
foreach ($ditems as $id => $item) {
|
foreach ($ditems as $id => $item) {
|
||||||
$product = $productRepository->getById($id,false, $store->getId(), false);
|
$product = $productRepository->getById($id,false, $store->getId(), false);
|
||||||
$product->setPrice($item['initialPrice']);
|
$product->setPrice($item['price_item']);
|
||||||
$quote->addProduct(
|
$quote->addProduct(
|
||||||
$product,
|
$product,
|
||||||
(int)$item['quantity']
|
(int)$item['quantity']
|
||||||
|
@ -520,7 +520,7 @@ class Exchange
|
||||||
{
|
{
|
||||||
$this->logger->writeDump($order, 'doUpdate');
|
$this->logger->writeDump($order, 'doUpdate');
|
||||||
|
|
||||||
$Status = $this->helper->getCongigStatus();
|
$Status = $this->config->getValue('retailcrm/retailcrm_status');
|
||||||
$Status = array_flip(array_filter($Status));
|
$Status = array_flip(array_filter($Status));
|
||||||
|
|
||||||
$magentoOrder = $this->order->load($order['externalId']);
|
$magentoOrder = $this->order->load($order['externalId']);
|
||||||
|
@ -627,6 +627,34 @@ class Exchange
|
||||||
$orders[$change['order']['id']]['order_edit'] = 1;
|
$orders[$change['order']['id']]['order_edit'] = 1;
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
|
if (isset($fields['delivery'][$change['field']])
|
||||||
|
&& $fields['delivery'][$change['field']] == 'service'
|
||||||
|
) {
|
||||||
|
$orders[$orderId]['delivery']['service']['code'] = self::newValue($change['newValue']);
|
||||||
|
} elseif (isset($fields['delivery'][$change['field']])) {
|
||||||
|
$field = $fields['delivery'][$change['field']];
|
||||||
|
$orders[$orderId]['delivery'][$field] = self::newValue($change['newValue']);
|
||||||
|
unset($field);
|
||||||
|
} elseif (isset($fields['orderAddress'][$change['field']])) {
|
||||||
|
$field = $fields['orderAddress'][$change['field']];
|
||||||
|
$orders[$orderId]['delivery']['address'][$field] = self::newValue($change['newValue']);
|
||||||
|
unset($field);
|
||||||
|
} elseif (isset($fields['integrationDelivery'][$change['field']])) {
|
||||||
|
$field = $fields['integrationDelivery'][$change['field']];
|
||||||
|
$orders[$orderId]['delivery']['service'][$field] = self::newValue($change['newValue']);
|
||||||
|
unset($field);
|
||||||
|
} elseif (isset($fields['customerContragent'][$change['field']])) {
|
||||||
|
$field = $fields['customerContragent'][$change['field']];
|
||||||
|
$orders[$orderId][$field] = self::newValue($change['newValue']);
|
||||||
|
unset($field);
|
||||||
|
} elseif (strripos($change['field'], 'custom_') !== false) {
|
||||||
|
$field = str_replace('custom_', '', $change['field']);
|
||||||
|
$orders[$orderId]['customFields'][$field] = self::newValue($change['newValue']);
|
||||||
|
unset($field);
|
||||||
|
} elseif (isset($fields['order'][$change['field']])) {
|
||||||
|
$orders[$orderId][$fields['order'][$change['field']]] = self::newValue($change['newValue']);
|
||||||
|
}
|
||||||
|
|
||||||
if (isset($change['created'])) {
|
if (isset($change['created'])) {
|
||||||
$orders[$orderId]['create'] = 1;
|
$orders[$orderId]['create'] = 1;
|
||||||
}
|
}
|
||||||
|
|
|
@ -53,11 +53,9 @@ class OrderUpdate implements \Magento\Framework\Event\ObserverInterface
|
||||||
$order = $observer->getEvent()->getOrder();
|
$order = $observer->getEvent()->getOrder();
|
||||||
|
|
||||||
if ($order) {
|
if ($order) {
|
||||||
$statusList = $this->helper->getCongigStatus();
|
|
||||||
|
|
||||||
$this->order = [
|
$this->order = [
|
||||||
'externalId' => $order->getId(),
|
'externalId' => $order->getId(),
|
||||||
'status' => $statusList[$order->getStatus()]
|
'status' => $this->config->getValue('retailcrm/retailcrm_status/' . $order->getStatus())
|
||||||
];
|
];
|
||||||
|
|
||||||
if ($order->getBaseTotalDue() == 0) {
|
if ($order->getBaseTotalDue() == 0) {
|
||||||
|
|
|
@ -79,17 +79,13 @@ class Customer implements CustomerManagerInterface
|
||||||
'index' => $billing->getPostcode(),
|
'index' => $billing->getPostcode(),
|
||||||
'region' => $billing->getRegion(),
|
'region' => $billing->getRegion(),
|
||||||
'city' => $billing->getCity(),
|
'city' => $billing->getCity(),
|
||||||
'street' => is_array($billing->getStreet())
|
'street' => $billing->getStreet(),
|
||||||
? implode(', ', $billing->getStreet())
|
|
||||||
: $billing->getStreet(),
|
|
||||||
'text' => sprintf(
|
'text' => sprintf(
|
||||||
'%s %s %s %s',
|
'%s %s %s %s',
|
||||||
$billing->getPostcode(),
|
$billing->getPostcode(),
|
||||||
$billing->getRegion(),
|
$billing->getRegion(),
|
||||||
$billing->getCity(),
|
$billing->getCity(),
|
||||||
is_array($billing->getStreet())
|
$billing->getStreet()
|
||||||
? implode(', ', $billing->getStreet())
|
|
||||||
: $billing->getStreet()
|
|
||||||
)
|
)
|
||||||
]
|
]
|
||||||
];
|
];
|
||||||
|
|
|
@ -3,7 +3,6 @@
|
||||||
namespace Retailcrm\Retailcrm\Model\Service;
|
namespace Retailcrm\Retailcrm\Model\Service;
|
||||||
|
|
||||||
use Retailcrm\Retailcrm\Helper\Data as Helper;
|
use Retailcrm\Retailcrm\Helper\Data as Helper;
|
||||||
use Magento\Framework\App\Config\ScopeConfigInterface;
|
|
||||||
|
|
||||||
class IntegrationModule
|
class IntegrationModule
|
||||||
{
|
{
|
||||||
|
@ -111,15 +110,9 @@ class IntegrationModule
|
||||||
}
|
}
|
||||||
|
|
||||||
if ($response->isSuccessful() && $active == true) {
|
if ($response->isSuccessful() && $active == true) {
|
||||||
|
|
||||||
$scope = ScopeConfigInterface::SCOPE_TYPE_DEFAULT;
|
|
||||||
$scopeId = 0;
|
|
||||||
|
|
||||||
$this->resourceConfig->saveConfig(
|
$this->resourceConfig->saveConfig(
|
||||||
Helper::XML_PATH_RETAILCRM . 'general/client_id_in_crm',
|
Helper::XML_PATH_RETAILCRM . 'general/client_id_in_crm',
|
||||||
$this->clientId,
|
$this->clientId
|
||||||
$scope,
|
|
||||||
$scopeId
|
|
||||||
);
|
);
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
|
|
|
@ -37,10 +37,6 @@ class Order implements \Retailcrm\Retailcrm\Api\OrderManagerInterface
|
||||||
$shippingAddress = $order->getShippingAddress();
|
$shippingAddress = $order->getShippingAddress();
|
||||||
$shipping = $this->getShippingCode($order->getShippingMethod());
|
$shipping = $this->getShippingCode($order->getShippingMethod());
|
||||||
|
|
||||||
$shipList = $this->helper->getCongigShipping();
|
|
||||||
$statusList = $this->helper->getCongigStatus();
|
|
||||||
$paymentList = $this->helper->getConfigPayments();
|
|
||||||
|
|
||||||
$preparedOrder = [
|
$preparedOrder = [
|
||||||
'externalId' => $order->getId(),
|
'externalId' => $order->getId(),
|
||||||
'number' => $order->getRealOrderId(),
|
'number' => $order->getRealOrderId(),
|
||||||
|
@ -50,10 +46,10 @@ class Order implements \Retailcrm\Retailcrm\Api\OrderManagerInterface
|
||||||
'patronymic' => $shippingAddress->getMiddlename(),
|
'patronymic' => $shippingAddress->getMiddlename(),
|
||||||
'email' => $shippingAddress->getEmail(),
|
'email' => $shippingAddress->getEmail(),
|
||||||
'phone' => $shippingAddress->getTelephone(),
|
'phone' => $shippingAddress->getTelephone(),
|
||||||
'status' => $statusList[$order->getStatus()],
|
'status' => $this->config->getValue('retailcrm/retailcrm_status/' . $order->getStatus()),
|
||||||
'items' => $products,
|
'items' => $products,
|
||||||
'delivery' => [
|
'delivery' => [
|
||||||
'code' => $shipList[$shipping],
|
'code' => $this->config->getValue('retailcrm/retailcrm_shipping/' . $shipping),
|
||||||
'cost' => $order->getShippingAmount(),
|
'cost' => $order->getShippingAmount(),
|
||||||
'address' => [
|
'address' => [
|
||||||
'index' => $shippingAddress->getData('postcode'),
|
'index' => $shippingAddress->getData('postcode'),
|
||||||
|
@ -84,11 +80,15 @@ class Order implements \Retailcrm\Retailcrm\Api\OrderManagerInterface
|
||||||
|
|
||||||
if ($this->helper->getGeneralSettings('api_version') == 'v4') {
|
if ($this->helper->getGeneralSettings('api_version') == 'v4') {
|
||||||
$preparedOrder['discount'] = abs($order->getDiscountAmount());
|
$preparedOrder['discount'] = abs($order->getDiscountAmount());
|
||||||
$preparedOrder['paymentType'] = $paymentList[$order->getPayment()->getMethodInstance()->getCode()];
|
$preparedOrder['paymentType'] = $this->config->getValue(
|
||||||
|
'retailcrm/retailcrm_payment/' . $order->getPayment()->getMethodInstance()->getCode()
|
||||||
|
);
|
||||||
} elseif ($this->helper->getGeneralSettings('api_version') == 'v5') {
|
} elseif ($this->helper->getGeneralSettings('api_version') == 'v5') {
|
||||||
$preparedOrder['discountManualAmount'] = abs($order->getDiscountAmount());
|
$preparedOrder['discountManualAmount'] = abs($order->getDiscountAmount());
|
||||||
$payment = [
|
$payment = [
|
||||||
'type'=> $paymentList[$order->getPayment()->getMethodInstance()->getCode()],
|
'type' => $this->config->getValue(
|
||||||
|
'retailcrm/retailcrm_payment/' . $order->getPayment()->getMethodInstance()->getCode()
|
||||||
|
),
|
||||||
'externalId' => $codeShop.$order->getId(),
|
'externalId' => $codeShop.$order->getId(),
|
||||||
'order' => [
|
'order' => [
|
||||||
'externalId' => $order->getId(),
|
'externalId' => $order->getId(),
|
||||||
|
|
|
@ -1 +1 @@
|
||||||
Magento 2 module for interaction with RetailCRM
|
Magento 2 module for interaction with retailCRM
|
|
@ -2,9 +2,7 @@
|
||||||
|
|
||||||
namespace Retailcrm\Retailcrm\Test\Helpers;
|
namespace Retailcrm\Retailcrm\Test\Helpers;
|
||||||
|
|
||||||
use Retailcrm\Retailcrm\Test\TestCase;
|
class FieldsetTest extends \PHPUnit\Framework\TestCase
|
||||||
|
|
||||||
class FieldsetTest extends TestCase
|
|
||||||
{
|
{
|
||||||
protected $elementMock;
|
protected $elementMock;
|
||||||
protected $authSessionMock;
|
protected $authSessionMock;
|
||||||
|
@ -20,7 +18,6 @@ class FieldsetTest extends TestCase
|
||||||
protected $testElementId = 'test_element_id';
|
protected $testElementId = 'test_element_id';
|
||||||
protected $testFieldSetCss = 'test_fieldset_css';
|
protected $testFieldSetCss = 'test_fieldset_css';
|
||||||
protected $objectFactory;
|
protected $objectFactory;
|
||||||
protected $secureRenderer;
|
|
||||||
|
|
||||||
public function setUp()
|
public function setUp()
|
||||||
{
|
{
|
||||||
|
@ -89,23 +86,6 @@ class FieldsetTest extends TestCase
|
||||||
$factoryCollection->expects($this->any())->method('create')->willReturn($elementCollection);
|
$factoryCollection->expects($this->any())->method('create')->willReturn($elementCollection);
|
||||||
$rendererMock = $this->createMock(\Magento\Framework\Data\Form\Element\Renderer\RendererInterface::class);
|
$rendererMock = $this->createMock(\Magento\Framework\Data\Form\Element\Renderer\RendererInterface::class);
|
||||||
|
|
||||||
if (class_exists(\Magento\Framework\View\Helper\SecureHtmlRenderer::class)) {
|
|
||||||
|
|
||||||
$this->secureRenderer = $this->createMock(\Magento\Framework\View\Helper\SecureHtmlRenderer::class);
|
|
||||||
$this->secureRenderer->method('renderEventListenerAsTag')
|
|
||||||
->willReturnCallback(
|
|
||||||
function (string $event, string $js, string $selector): string {
|
|
||||||
return "<script>document.querySelector('$selector').$event = function () { $js };</script>";
|
|
||||||
}
|
|
||||||
);
|
|
||||||
$this->secureRenderer->method('renderStyleAsTag')
|
|
||||||
->willReturnCallback(
|
|
||||||
function (string $style, string $selector): string {
|
|
||||||
return "<style>$selector { $style }</style>";
|
|
||||||
}
|
|
||||||
);
|
|
||||||
}
|
|
||||||
|
|
||||||
$this->urlModelMock = $this->createMock(\Magento\Backend\Model\Url::class);
|
$this->urlModelMock = $this->createMock(\Magento\Backend\Model\Url::class);
|
||||||
$this->layoutMock = $this->createMock(\Magento\Framework\View\Layout::class);
|
$this->layoutMock = $this->createMock(\Magento\Framework\View\Layout::class);
|
||||||
$this->groupMock = $this->createMock(\Magento\Config\Model\Config\Structure\Element\Group::class);
|
$this->groupMock = $this->createMock(\Magento\Config\Model\Config\Structure\Element\Group::class);
|
||||||
|
@ -118,10 +98,9 @@ class FieldsetTest extends TestCase
|
||||||
$this->helperMock = $this->createMock(\Magento\Framework\View\Helper\Js::class);
|
$this->helperMock = $this->createMock(\Magento\Framework\View\Helper\Js::class);
|
||||||
$this->form = $this->createPartialMock(
|
$this->form = $this->createPartialMock(
|
||||||
\Magento\Config\Block\System\Config\Form::class,
|
\Magento\Config\Block\System\Config\Form::class,
|
||||||
//['getElements', 'getRequest']
|
['getElements', 'getRequest']
|
||||||
['getRequest']
|
|
||||||
);
|
);
|
||||||
//$this->form->expects($this->any())->method('getElements')->willReturn($elementCollection);
|
$this->form->expects($this->any())->method('getElements')->willReturn($elementCollection);
|
||||||
$this->form->expects($this->any())->method('getRequest')->willReturn($this->requestMock);
|
$this->form->expects($this->any())->method('getRequest')->willReturn($this->requestMock);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,58 +0,0 @@
|
||||||
<?php
|
|
||||||
|
|
||||||
namespace Retailcrm\Retailcrm\Test;
|
|
||||||
|
|
||||||
// backward compatibility with phpunit < v.6
|
|
||||||
if (!class_exists('\PHPUnit\Framework\TestCase')) {
|
|
||||||
class_alias('\PHPUnit_Framework_TestCase', '\PHPUnit\Framework\TestCase');
|
|
||||||
|
|
||||||
abstract class TestCase extends \PHPUnit\Framework\TestCase
|
|
||||||
{
|
|
||||||
public function createMock($originalClassName)
|
|
||||||
{
|
|
||||||
if (method_exists(\PHPUnit\Framework\TestCase::class, 'createMock')) {
|
|
||||||
return parent::createMock($originalClassName);
|
|
||||||
} else {
|
|
||||||
return $this->getMockBuilder($originalClassName)
|
|
||||||
->disableOriginalConstructor()
|
|
||||||
->disableOriginalClone()
|
|
||||||
->disableArgumentCloning()
|
|
||||||
->getMock();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
protected function createPartialMock($originalClassName, $methods)
|
|
||||||
{
|
|
||||||
if (method_exists(\PHPUnit\Framework\TestCase::class, 'createPartialMock')) {
|
|
||||||
return parent::createMock($originalClassName);
|
|
||||||
} else {
|
|
||||||
return $this->getMockBuilder($originalClassName)
|
|
||||||
->disableOriginalConstructor()
|
|
||||||
->disableOriginalClone()
|
|
||||||
->disableArgumentCloning()
|
|
||||||
// ->disallowMockingUnknownTypes()
|
|
||||||
->setMethods(empty($methods) ? null : $methods)
|
|
||||||
->getMock();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
|
|
||||||
abstract class TestCase extends \PHPUnit\Framework\TestCase
|
|
||||||
{
|
|
||||||
public function createMock($originalClassName)
|
|
||||||
{
|
|
||||||
if (method_exists(\PHPUnit\Framework\TestCase::class, 'createMock')) {
|
|
||||||
return parent::createMock($originalClassName);
|
|
||||||
} else {
|
|
||||||
return $this->getMockBuilder($originalClassName)
|
|
||||||
->disableOriginalConstructor()
|
|
||||||
->disableOriginalClone()
|
|
||||||
->disableArgumentCloning()
|
|
||||||
->getMock();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
|
@ -52,8 +52,7 @@ class PaymentTest extends \Retailcrm\Retailcrm\Test\Helpers\FieldsetTest
|
||||||
'client' => $client,
|
'client' => $client,
|
||||||
'paymentConfig' => $paymentConfig,
|
'paymentConfig' => $paymentConfig,
|
||||||
'context' => $this->context,
|
'context' => $this->context,
|
||||||
'objectFactory' => $this->objectFactory,
|
'objectFactory' => $this->objectFactory
|
||||||
'secureRenderer' => $this->secureRenderer
|
|
||||||
];
|
];
|
||||||
|
|
||||||
$payment = $this->objectManager->getObject(
|
$payment = $this->objectManager->getObject(
|
||||||
|
|
|
@ -52,8 +52,7 @@ class ShippingTest extends \Retailcrm\Retailcrm\Test\Helpers\FieldsetTest
|
||||||
'client' => $client,
|
'client' => $client,
|
||||||
'shippingConfig' => $shippingConfig,
|
'shippingConfig' => $shippingConfig,
|
||||||
'context' => $this->context,
|
'context' => $this->context,
|
||||||
'objectFactory' => $this->objectFactory,
|
'objectFactory' => $this->objectFactory
|
||||||
'secureRenderer' => $this->secureRenderer
|
|
||||||
];
|
];
|
||||||
|
|
||||||
$shipping = $this->objectManager->getObject(
|
$shipping = $this->objectManager->getObject(
|
||||||
|
|
|
@ -43,8 +43,7 @@ class SiteTest extends \Retailcrm\Retailcrm\Test\Helpers\FieldsetTest
|
||||||
'data' => ['group' => $this->groupMock],
|
'data' => ['group' => $this->groupMock],
|
||||||
'client' => $client,
|
'client' => $client,
|
||||||
'context' => $this->context,
|
'context' => $this->context,
|
||||||
'objectFactory' => $this->objectFactory,
|
'objectFactory' => $this->objectFactory
|
||||||
'secureRenderer' => $this->secureRenderer
|
|
||||||
];
|
];
|
||||||
|
|
||||||
$site = $this->objectManager->getObject(
|
$site = $this->objectManager->getObject(
|
||||||
|
|
|
@ -55,8 +55,7 @@ class SitesTest extends \Retailcrm\Retailcrm\Test\Helpers\FieldsetTest
|
||||||
'client' => $client,
|
'client' => $client,
|
||||||
'storeManager' => $storeManager,
|
'storeManager' => $storeManager,
|
||||||
'context' => $this->context,
|
'context' => $this->context,
|
||||||
'objectFactory' => $this->objectFactory,
|
'objectFactory' => $this->objectFactory
|
||||||
'secureRenderer' => $this->secureRenderer
|
|
||||||
];
|
];
|
||||||
|
|
||||||
$sites = $this->objectManager->getObject(
|
$sites = $this->objectManager->getObject(
|
||||||
|
|
|
@ -52,8 +52,7 @@ class StatusTest extends \Retailcrm\Retailcrm\Test\Helpers\FieldsetTest
|
||||||
'client' => $client,
|
'client' => $client,
|
||||||
'statusCollection' => $statusCollection,
|
'statusCollection' => $statusCollection,
|
||||||
'context' => $this->context,
|
'context' => $this->context,
|
||||||
'objectFactory' => $this->objectFactory,
|
'objectFactory' => $this->objectFactory
|
||||||
'secureRenderer' => $this->secureRenderer
|
|
||||||
];
|
];
|
||||||
|
|
||||||
$status = $this->objectManager->getObject(
|
$status = $this->objectManager->getObject(
|
||||||
|
|
|
@ -2,9 +2,7 @@
|
||||||
|
|
||||||
namespace Retailcrm\Retailcrm\Test\Unit\Block\Frontend;
|
namespace Retailcrm\Retailcrm\Test\Unit\Block\Frontend;
|
||||||
|
|
||||||
use Retailcrm\Retailcrm\Test\TestCase;
|
class DaemonCollectorTest extends \PHPUnit\Framework\TestCase
|
||||||
|
|
||||||
class DaemonCollectorTest extends TestCase
|
|
||||||
{
|
{
|
||||||
private $unit;
|
private $unit;
|
||||||
private $customer;
|
private $customer;
|
||||||
|
|
|
@ -2,9 +2,7 @@
|
||||||
|
|
||||||
namespace Retailcrm\Retailcrm\Test\Unit\Model\Observer;
|
namespace Retailcrm\Retailcrm\Test\Unit\Model\Observer;
|
||||||
|
|
||||||
use Retailcrm\Retailcrm\Test\TestCase;
|
class CustomerTest extends \PHPUnit\Framework\TestCase
|
||||||
|
|
||||||
class CustomerTest extends TestCase
|
|
||||||
{
|
{
|
||||||
private $mockApi;
|
private $mockApi;
|
||||||
private $mockResponse;
|
private $mockResponse;
|
||||||
|
|
|
@ -2,12 +2,10 @@
|
||||||
|
|
||||||
namespace Retailcrm\Retailcrm\Test\Unit\Observer;
|
namespace Retailcrm\Retailcrm\Test\Unit\Observer;
|
||||||
|
|
||||||
use Retailcrm\Retailcrm\Test\TestCase;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Order create observer test class
|
* Order create observer test class
|
||||||
*/
|
*/
|
||||||
class OrderCreateTest extends TestCase
|
class OrderCreateTest extends \PHPUnit\Framework\TestCase
|
||||||
{
|
{
|
||||||
private $unit;
|
private $unit;
|
||||||
private $mockEvent;
|
private $mockEvent;
|
||||||
|
|
|
@ -2,9 +2,7 @@
|
||||||
|
|
||||||
namespace Retailcrm\Retailcrm\Test\Unit\Observer;
|
namespace Retailcrm\Retailcrm\Test\Unit\Observer;
|
||||||
|
|
||||||
use Retailcrm\Retailcrm\Test\TestCase;
|
class OrderUpdateTest extends \PHPUnit\Framework\TestCase
|
||||||
|
|
||||||
class OrderUpdateTest extends TestCase
|
|
||||||
{
|
{
|
||||||
private $unit;
|
private $unit;
|
||||||
private $objectManager;
|
private $objectManager;
|
||||||
|
|
|
@ -2,9 +2,7 @@
|
||||||
|
|
||||||
namespace Retailcrm\Retailcrm\Test\Unit\Model\Service;
|
namespace Retailcrm\Retailcrm\Test\Unit\Model\Service;
|
||||||
|
|
||||||
use Retailcrm\Retailcrm\Test\TestCase;
|
class CustomerTest extends \PHPUnit\Framework\TestCase
|
||||||
|
|
||||||
class CustomerTest extends TestCase
|
|
||||||
{
|
{
|
||||||
private $mockData;
|
private $mockData;
|
||||||
private $mockCustomer;
|
private $mockCustomer;
|
||||||
|
|
|
@ -2,9 +2,7 @@
|
||||||
|
|
||||||
namespace Retailcrm\Retailcrm\Test\Unit\Model\Service;
|
namespace Retailcrm\Retailcrm\Test\Unit\Model\Service;
|
||||||
|
|
||||||
use Retailcrm\Retailcrm\Test\TestCase;
|
class IntegrationModuleTest extends \PHPUnit\Framework\TestCase
|
||||||
|
|
||||||
class IntegrationModuleTest extends TestCase
|
|
||||||
{
|
{
|
||||||
private $mockResourceConfig;
|
private $mockResourceConfig;
|
||||||
private $mockApiClient;
|
private $mockApiClient;
|
||||||
|
|
|
@ -2,9 +2,7 @@
|
||||||
|
|
||||||
namespace Retailcrm\Retailcrm\Test\Unit\Model\Service;
|
namespace Retailcrm\Retailcrm\Test\Unit\Model\Service;
|
||||||
|
|
||||||
use Retailcrm\Retailcrm\Test\TestCase;
|
class InventoriesUploadTest extends \PHPUnit\Framework\TestCase
|
||||||
|
|
||||||
class InventoriesUploadTest extends TestCase
|
|
||||||
{
|
{
|
||||||
private $mockApi;
|
private $mockApi;
|
||||||
private $mockProductRepository;
|
private $mockProductRepository;
|
||||||
|
@ -20,12 +18,12 @@ class InventoriesUploadTest extends TestCase
|
||||||
'isConfigured'
|
'isConfigured'
|
||||||
])
|
])
|
||||||
->getMock();
|
->getMock();
|
||||||
|
|
||||||
$this->mockProductRepository = $this->getMockBuilder(\Magento\Catalog\Api\ProductRepositoryInterface::class)
|
$this->mockProductRepository = $this->getMockBuilder(\Magento\Catalog\Api\ProductRepositoryInterface::class)
|
||||||
->disableOriginalConstructor()
|
->disableOriginalConstructor()
|
||||||
->setMethods(['getById'])
|
->setMethods(['getById'])
|
||||||
->getMockForAbstractClass();
|
->getMockForAbstractClass();
|
||||||
|
|
||||||
$this->mockResponse = $this->getMockBuilder(\RetailCrm\Response\ApiResponse::class)
|
$this->mockResponse = $this->getMockBuilder(\RetailCrm\Response\ApiResponse::class)
|
||||||
->disableOriginalConstructor()
|
->disableOriginalConstructor()
|
||||||
->setMethods(['isSuccessful'])
|
->setMethods(['isSuccessful'])
|
||||||
|
@ -49,7 +47,6 @@ class InventoriesUploadTest extends TestCase
|
||||||
{
|
{
|
||||||
if ($response != false) {
|
if ($response != false) {
|
||||||
$responseInventories = new \RetailCrm\Response\ApiResponse(200, json_encode($response));
|
$responseInventories = new \RetailCrm\Response\ApiResponse(200, json_encode($response));
|
||||||
$responseInventories->asJsonResponse($response);
|
|
||||||
|
|
||||||
$this->mockResponse->expects($this->any())
|
$this->mockResponse->expects($this->any())
|
||||||
->method('isSuccessful')
|
->method('isSuccessful')
|
||||||
|
@ -91,9 +88,9 @@ class InventoriesUploadTest extends TestCase
|
||||||
}
|
}
|
||||||
|
|
||||||
public function dataProviderLoadStocks()
|
public function dataProviderLoadStocks()
|
||||||
{
|
{
|
||||||
$response = $this->getResponseData();
|
$response = $this->getResponseData();
|
||||||
|
|
||||||
return array(
|
return array(
|
||||||
array(
|
array(
|
||||||
'response' => $response['true']
|
'response' => $response['true']
|
||||||
|
@ -103,7 +100,7 @@ class InventoriesUploadTest extends TestCase
|
||||||
)
|
)
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
private function getApiInventories()
|
private function getApiInventories()
|
||||||
{
|
{
|
||||||
return array(
|
return array(
|
||||||
|
|
|
@ -2,9 +2,7 @@
|
||||||
|
|
||||||
namespace Retailcrm\Retailcrm\Test\Unit\Model\Service;
|
namespace Retailcrm\Retailcrm\Test\Unit\Model\Service;
|
||||||
|
|
||||||
use Retailcrm\Retailcrm\Test\TestCase;
|
class OrderTest extends \PHPUnit\Framework\TestCase
|
||||||
|
|
||||||
class OrderTest extends TestCase
|
|
||||||
{
|
{
|
||||||
private $mockProductRepository;
|
private $mockProductRepository;
|
||||||
private $mockHelper;
|
private $mockHelper;
|
||||||
|
@ -52,13 +50,11 @@ class OrderTest extends TestCase
|
||||||
$this->mockHelper->expects($this->any())->method('getGeneralSettings')
|
$this->mockHelper->expects($this->any())->method('getGeneralSettings')
|
||||||
->with('api_version')->willReturn($apiVersion);
|
->with('api_version')->willReturn($apiVersion);
|
||||||
|
|
||||||
$this->mockHelper->expects($this->any())->method('getConfigPayments')->willReturn(['checkmo'=>'test']);
|
|
||||||
$this->mockHelper->expects($this->any())->method('getCongigStatus')->willReturn(['processing'=>'test']);
|
|
||||||
$this->mockHelper->expects($this->any())->method('getCongigShipping')->willReturn(['flatrate'=>'test']);
|
|
||||||
|
|
||||||
$this->mockConfig->expects($this->any())->method('getValue')
|
$this->mockConfig->expects($this->any())->method('getValue')
|
||||||
->with($this->logicalOr(
|
->with($this->logicalOr(
|
||||||
$this->equalTo('retailcrm/retailcrm_site/default')
|
$this->equalTo('retailcrm/retailcrm_status/processing'),
|
||||||
|
$this->equalTo('retailcrm/retailcrm_payment/checkmo'),
|
||||||
|
$this->equalTo('retailcrm/retailcrm_shipping/flatrate')
|
||||||
))->will($this->returnCallback([$this, 'getCallbackDataConfig']));
|
))->will($this->returnCallback([$this, 'getCallbackDataConfig']));
|
||||||
|
|
||||||
$mockProduct = $this->getMockBuilder(\Magento\Catalog\Model\Product::class)
|
$mockProduct = $this->getMockBuilder(\Magento\Catalog\Model\Product::class)
|
||||||
|
@ -169,7 +165,9 @@ class OrderTest extends TestCase
|
||||||
public function getCallbackDataConfig($key)
|
public function getCallbackDataConfig($key)
|
||||||
{
|
{
|
||||||
$data = [
|
$data = [
|
||||||
'retailcrm/retailcrm_site/default' => 'test'
|
'retailcrm/retailcrm_status/processing' => 'new',
|
||||||
|
'retailcrm/retailcrm_payment/checkmo' => 'test',
|
||||||
|
'retailcrm/retailcrm_shipping/flatrate' => 'test'
|
||||||
];
|
];
|
||||||
|
|
||||||
return $data[$key];
|
return $data[$key];
|
||||||
|
|
|
@ -1,11 +1,11 @@
|
||||||
{
|
{
|
||||||
"name": "retailcrm/retailcrm",
|
"name": "retailcrm/retailcrm",
|
||||||
"description": "RetailCRM",
|
"description": "Retailcrm",
|
||||||
"require": {
|
"require": {
|
||||||
"retailcrm/api-client-php": "~5.0"
|
"retailcrm/api-client-php": "~5.0"
|
||||||
},
|
},
|
||||||
"type": "magento2-module",
|
"type": "magento2-module",
|
||||||
"version": "2.5.2",
|
"version": "2.4.1",
|
||||||
"license": [
|
"license": [
|
||||||
"OSL-3.0",
|
"OSL-3.0",
|
||||||
"AFL-3.0"
|
"AFL-3.0"
|
||||||
|
|
|
@ -2,7 +2,7 @@
|
||||||
<config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:module:Magento_Config:etc/system_file.xsd">
|
<config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:module:Magento_Config:etc/system_file.xsd">
|
||||||
<system>
|
<system>
|
||||||
<tab id="retailcrm" translate="label" sortOrder="10">
|
<tab id="retailcrm" translate="label" sortOrder="10">
|
||||||
<label>RetailCRM</label>
|
<label>Retailcrm</label>
|
||||||
</tab>
|
</tab>
|
||||||
<section id="retailcrm" translate="label" sortOrder="130" showInDefault="1" showInWebsite="1" showInStore="1">
|
<section id="retailcrm" translate="label" sortOrder="130" showInDefault="1" showInWebsite="1" showInStore="1">
|
||||||
<class>separator-top</class>
|
<class>separator-top</class>
|
||||||
|
@ -18,7 +18,7 @@
|
||||||
</field>
|
</field>
|
||||||
<field id="api_key" translate="label" type="text" sortOrder="20" showInDefault="1" showInWebsite="1" showInStore="1">
|
<field id="api_key" translate="label" type="text" sortOrder="20" showInDefault="1" showInWebsite="1" showInStore="1">
|
||||||
<label>API key</label>
|
<label>API key</label>
|
||||||
<comment>You can create an API key in the administration section of RetailCRM</comment>
|
<comment>You can create an API key in the administration section of retailCRM</comment>
|
||||||
</field>
|
</field>
|
||||||
<field id="api_version" translate="label" type="select" sortOrder="30" showInDefault="1" showInWebsite="1" showInStore="1">
|
<field id="api_version" translate="label" type="select" sortOrder="30" showInDefault="1" showInWebsite="1" showInStore="1">
|
||||||
<label>API version</label>
|
<label>API version</label>
|
||||||
|
@ -34,29 +34,17 @@
|
||||||
<source_model>Retailcrm\Retailcrm\Model\Setting\Attribute</source_model>
|
<source_model>Retailcrm\Retailcrm\Model\Setting\Attribute</source_model>
|
||||||
</field>
|
</field>
|
||||||
</group>
|
</group>
|
||||||
<group id="shippingList" translate="label" type="select" sortOrder="30" showInDefault="1" showInWebsite="1" showInStore="1">
|
<group id="shipping" translate="label" type="select" sortOrder="30" showInDefault="1" showInWebsite="1" showInStore="1">
|
||||||
<label>Delivery types</label>
|
<label>Delivery types</label>
|
||||||
<field id="shippingList" translate="label" sortOrder="5" showInDefault="1" showInWebsite="1" showInStore="1">
|
<frontend_model>Retailcrm\Retailcrm\Block\Adminhtml\System\Config\Form\Fieldset\Shipping</frontend_model>
|
||||||
<label>shipping settings</label>
|
|
||||||
<frontend_model>Retailcrm\Retailcrm\Block\Adminhtml\System\Config\Form\Fieldset\ShippingList</frontend_model>
|
|
||||||
<backend_model>Magento\Config\Model\Config\Backend\Serialized\ArraySerialized</backend_model>
|
|
||||||
</field>
|
|
||||||
</group>
|
</group>
|
||||||
<group id="paymentList" translate="label" type="select" sortOrder="30" showInDefault="1" showInWebsite="1" showInStore="1">
|
<group id="payment" translate="label comment" type="select" sortOrder="40" showInDefault="1" showInWebsite="1" showInStore="1">
|
||||||
<label>Payment types</label>
|
<label>Payment types</label>
|
||||||
<field id="paymentList" translate="label" sortOrder="5" showInDefault="1" showInWebsite="1" showInStore="1">
|
<frontend_model>Retailcrm\Retailcrm\Block\Adminhtml\System\Config\Form\Fieldset\Payment</frontend_model>
|
||||||
<label>payment settings</label>
|
|
||||||
<frontend_model>Retailcrm\Retailcrm\Block\Adminhtml\System\Config\Form\Fieldset\PaymentList</frontend_model>
|
|
||||||
<backend_model>Magento\Config\Model\Config\Backend\Serialized\ArraySerialized</backend_model>
|
|
||||||
</field>
|
|
||||||
</group>
|
</group>
|
||||||
<group id="statusList" translate="label" type="select" sortOrder="30" showInDefault="1" showInWebsite="1" showInStore="1">
|
<group id="status" translate="label" type="select" sortOrder="50" showInDefault="1" showInWebsite="1" showInStore="1">
|
||||||
<label>Status types</label>
|
<label>Order statuses</label>
|
||||||
<field id="statusList" translate="label" sortOrder="5" showInDefault="1" showInWebsite="1" showInStore="1">
|
<frontend_model>Retailcrm\Retailcrm\Block\Adminhtml\System\Config\Form\Fieldset\Status</frontend_model>
|
||||||
<label>status settings</label>
|
|
||||||
<frontend_model>Retailcrm\Retailcrm\Block\Adminhtml\System\Config\Form\Fieldset\StatusList</frontend_model>
|
|
||||||
<backend_model>Magento\Config\Model\Config\Backend\Serialized\ArraySerialized</backend_model>
|
|
||||||
</field>
|
|
||||||
</group>
|
</group>
|
||||||
<group id="load" translate="label" type="text" sortOrder="80" showInDefault="1" showInWebsite="1" showInStore="1">
|
<group id="load" translate="label" type="text" sortOrder="80" showInDefault="1" showInWebsite="1" showInStore="1">
|
||||||
<label>Uploading orders</label>
|
<label>Uploading orders</label>
|
||||||
|
|
|
@ -1,7 +1,7 @@
|
||||||
"Settings","La configuración"
|
"Settings","La configuración"
|
||||||
"Main settings","La configuración general"
|
"Main settings","La configuración general"
|
||||||
"API key","La llave API"
|
"API key","La llave API"
|
||||||
"You can create an API key in the administration section of RetailCRM","Puede crear la llave API en la sección administrativa del RetailCRM"
|
"You can create an API key in the administration section of retailCRM","Puede crear la llave API en la sección administrativa del retailCRM"
|
||||||
"API version","La versión API"
|
"API version","La versión API"
|
||||||
"Catalogue settings","La configuración del catálogo"
|
"Catalogue settings","La configuración del catálogo"
|
||||||
"Attributes for uploading to ICML","Los atributos para importar al ICML"
|
"Attributes for uploading to ICML","Los atributos para importar al ICML"
|
||||||
|
@ -15,10 +15,10 @@
|
||||||
"Setting the store by default","La configuración de la tienda por defecto"
|
"Setting the store by default","La configuración de la tienda por defecto"
|
||||||
"Setting the stores correspondence","La configuración de la concordancia de tienda"
|
"Setting the stores correspondence","La configuración de la concordancia de tienda"
|
||||||
"Enter API of your URL and API key","Introduce el enlace API y la llave API"
|
"Enter API of your URL and API key","Introduce el enlace API y la llave API"
|
||||||
"Incorrect URL of RetailCRM","La dirección del RetailCRM es incorrecto"
|
"Incorrect URL of retailCRM","La dirección del retailCRM es incorrecto"
|
||||||
"Make sure that the entered data is correct","Asegúrese de que los datos introducidos son correctos"
|
"Make sure that the entered data is correct","Asegúrese de que los datos introducidos son correctos"
|
||||||
"Incorrect API key","La llave API es incorrecta"
|
"Incorrect API key","La llave API es incorrecta"
|
||||||
"Incorrect URL of RetailCRM or API key","La dirección del RetailCRM o la llave API son incorrectos"
|
"Incorrect URL of retailCRM or API key","La dirección del retailCRM o la llave API son incorrectos"
|
||||||
"The selected API version is unavailable","La versión de la API seleccionada no está disponible"
|
"The selected API version is unavailable","La versión de la API seleccionada no está disponible"
|
||||||
"Send","Enviar"
|
"Send","Enviar"
|
||||||
"Default site","Tienda por defecto"
|
"Default site","Tienda por defecto"
|
||||||
|
|
|
|
@ -1,7 +1,7 @@
|
||||||
"Settings","Настройки"
|
"Settings","Настройки"
|
||||||
"Main settings","Главные настройки"
|
"Main settings","Главные настройки"
|
||||||
"API key","API ключ"
|
"API key","API ключ"
|
||||||
"You can create an API key in the administration section of RetailCRM","Вы можете создать API ключ в административном разделе RetailCRM"
|
"You can create an API key in the administration section of retailCRM","Вы можете создать API ключ в административном разделе retailCRM"
|
||||||
"API version","Версия API"
|
"API version","Версия API"
|
||||||
"Catalogue settings","Настройки каталога"
|
"Catalogue settings","Настройки каталога"
|
||||||
"Attributes for uploading to ICML","Атрибуты для выгрузки в ICML"
|
"Attributes for uploading to ICML","Атрибуты для выгрузки в ICML"
|
||||||
|
@ -15,10 +15,10 @@
|
||||||
"Setting the store by default","Настройка магазина по умолчанию"
|
"Setting the store by default","Настройка магазина по умолчанию"
|
||||||
"Setting the stores correspondence","Настройка соответствия магазинов"
|
"Setting the stores correspondence","Настройка соответствия магазинов"
|
||||||
"Enter API of your URL and API key","Введите Ваш API URL и API ключ"
|
"Enter API of your URL and API key","Введите Ваш API URL и API ключ"
|
||||||
"Incorrect URL of RetailCRM","Некорректный адрес RetailCRM"
|
"Incorrect URL of retailCRM","Некорректный адрес retailCRM"
|
||||||
"Make sure that the entered data is correct","Убедитесь, что введенные данные верны"
|
"Make sure that the entered data is correct","Убедитесь, что введенные данные верны"
|
||||||
"Incorrect API key","Некорректный API ключ"
|
"Incorrect API key","Некорректный API ключ"
|
||||||
"Incorrect URL of RetailCRM or API key","Некорректный адрес RetailCRM или API ключ"
|
"Incorrect URL of retailCRM or API key","Некорректный адрес retailCRM или API ключ"
|
||||||
"The selected API version is unavailable","Выбранная версия API недоступна"
|
"The selected API version is unavailable","Выбранная версия API недоступна"
|
||||||
"Send","Выгрузить"
|
"Send","Выгрузить"
|
||||||
"Default site","Сайт по умолчанию"
|
"Default site","Сайт по умолчанию"
|
||||||
|
|
|
Loading…
Add table
Reference in a new issue