Compare commits
No commits in common. "master" and "v2.4.0" have entirely different histories.
56 changed files with 245 additions and 1459 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
|
|
40
.travis.yml
Normal file
40
.travis.yml
Normal file
|
@ -0,0 +1,40 @@
|
||||||
|
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.0
|
||||||
|
env: BRANCH=2.2-develop
|
||||||
|
- php: 7.1
|
||||||
|
env: BRANCH=2.2-develop
|
||||||
|
- php: 7.1
|
||||||
|
env: BRANCH=2.3-develop
|
||||||
|
- php: 7.2
|
||||||
|
env: BRANCH=2.3-develop
|
||||||
|
|
||||||
|
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,23 +1,11 @@
|
||||||
## 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.4.1
|
|
||||||
* Удалена генерация 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
|
||||||
* Добавлены консольные команды для выгрузки архива клиентов и заказов
|
* Добавлены консольные команды для выгрузки архива клиентов и заказов
|
||||||
|
@ -27,4 +15,4 @@
|
||||||
* При формировании каталога выгружаются выбранные атрибуты товаров
|
* При формировании каталога выгружаются выбранные атрибуты товаров
|
||||||
* Улучшена выгрузка товаров в заказе (теперь учитываются конфигурируемые товары)
|
* Улучшена выгрузка товаров в заказе (теперь учитываются конфигурируемые товары)
|
||||||
* Добавлены переводы на русский и испанский языки
|
* Добавлены переводы на русский и испанский языки
|
||||||
* Из обработки истории удален менеджер объектов
|
* Из обработки истории удален менеджер объектов
|
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
|
|
18
README.md
18
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
|
||||||
|
|
||||||
|
@ -33,4 +29,4 @@ By default ICML file is being generated by module every 4 hours. You can find fi
|
||||||
composer require retailcrm/api-client-php ~5.0
|
composer require retailcrm/api-client-php ~5.0
|
||||||
```
|
```
|
||||||
|
|
||||||
This module is compatible with Magento up to version 2.2.8
|
This module is compatible with Magento up to version 2.2.3
|
||||||
|
|
27
README.ru.md
27
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
|
||||||
|
|
||||||
## Ручная установка
|
## Ручная установка
|
||||||
|
|
||||||
|
@ -27,4 +36,4 @@ composer require retailcrm/api-client-php ~5.0
|
||||||
В конфигурационный файл `composer.json` вашего проекта будет добавлена библиотека [retailcrm/api-client-php](https://github.com/retailcrm/api-client-php), которая будет установлена в директорию `vendor/`.
|
В конфигурационный файл `composer.json` вашего проекта будет добавлена библиотека [retailcrm/api-client-php](https://github.com/retailcrm/api-client-php), которая будет установлена в директорию `vendor/`.
|
||||||
|
|
||||||
|
|
||||||
Этот модуль совместим с Magento 2 до версии 2.2.8
|
Этот модуль совместим с Magento 2 до версии 2.2.3
|
||||||
|
|
2
VERSION
2
VERSION
|
@ -1 +1 @@
|
||||||
2.5.2
|
2.4.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
|
|
@ -82,6 +82,7 @@ class Payment extends \Magento\Config\Block\System\Config\Form\Fieldset
|
||||||
|
|
||||||
if ($this->client->isConfigured()) {
|
if ($this->client->isConfigured()) {
|
||||||
$paymentMethods = $this->paymentConfig->getActiveMethods();
|
$paymentMethods = $this->paymentConfig->getActiveMethods();
|
||||||
|
|
||||||
foreach ($paymentMethods as $code => $payment) {
|
foreach ($paymentMethods as $code => $payment) {
|
||||||
$html .= $this->_getFieldHtml($element, $payment);
|
$html .= $this->_getFieldHtml($element, $payment);
|
||||||
}
|
}
|
||||||
|
@ -116,7 +117,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;
|
||||||
|
@ -136,7 +137,7 @@ class Payment extends \Magento\Config\Block\System\Config\Form\Fieldset
|
||||||
* Get field html
|
* Get field html
|
||||||
*
|
*
|
||||||
* @param \Magento\Framework\Data\Form\Element\AbstractElement $fieldset
|
* @param \Magento\Framework\Data\Form\Element\AbstractElement $fieldset
|
||||||
* @param \Magento\Payment\Api\Data\PaymentMethodInterface $payment
|
* @param \Magento\Payment\Model\Method\AbstractMethod $payment
|
||||||
*
|
*
|
||||||
* @return string
|
* @return string
|
||||||
*/
|
*/
|
||||||
|
@ -144,7 +145,9 @@ class Payment extends \Magento\Config\Block\System\Config\Form\Fieldset
|
||||||
{
|
{
|
||||||
$configData = $this->getConfigData();
|
$configData = $this->getConfigData();
|
||||||
$path = 'retailcrm/' . $fieldset->getId() . '/' . $payment->getCode();
|
$path = 'retailcrm/' . $fieldset->getId() . '/' . $payment->getCode();
|
||||||
|
|
||||||
$data = isset($configData[$path]) ? $configData[$path] : [];
|
$data = isset($configData[$path]) ? $configData[$path] : [];
|
||||||
|
|
||||||
$e = $this->_getDummyElement();
|
$e = $this->_getDummyElement();
|
||||||
|
|
||||||
$field = $fieldset->addField(
|
$field = $fieldset->addField(
|
||||||
|
|
|
@ -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);
|
|
||||||
}
|
|
||||||
}
|
|
|
@ -6,6 +6,7 @@ class DaemonCollector extends \Magento\Framework\View\Element\Template
|
||||||
{
|
{
|
||||||
private $customer;
|
private $customer;
|
||||||
private $helper;
|
private $helper;
|
||||||
|
private $storeManager;
|
||||||
private $storeResolver;
|
private $storeResolver;
|
||||||
private $js = '';
|
private $js = '';
|
||||||
|
|
||||||
|
@ -22,6 +23,7 @@ EOT;
|
||||||
*
|
*
|
||||||
* @param \Magento\Framework\View\Element\Template\Context $context
|
* @param \Magento\Framework\View\Element\Template\Context $context
|
||||||
* @param \Magento\Customer\Model\Session $customerSession
|
* @param \Magento\Customer\Model\Session $customerSession
|
||||||
|
* @param \Magento\Store\Model\StoreManagerInterface $storeManager
|
||||||
* @param \Magento\Store\Api\StoreResolverInterface $storeResolver
|
* @param \Magento\Store\Api\StoreResolverInterface $storeResolver
|
||||||
* @param \Retailcrm\Retailcrm\Helper\Data $helper
|
* @param \Retailcrm\Retailcrm\Helper\Data $helper
|
||||||
* @param array $data
|
* @param array $data
|
||||||
|
@ -29,12 +31,14 @@ EOT;
|
||||||
public function __construct(
|
public function __construct(
|
||||||
\Magento\Framework\View\Element\Template\Context $context,
|
\Magento\Framework\View\Element\Template\Context $context,
|
||||||
\Magento\Customer\Model\Session $customerSession,
|
\Magento\Customer\Model\Session $customerSession,
|
||||||
|
\Magento\Store\Model\StoreManagerInterface $storeManager,
|
||||||
\Magento\Store\Api\StoreResolverInterface $storeResolver,
|
\Magento\Store\Api\StoreResolverInterface $storeResolver,
|
||||||
\Retailcrm\Retailcrm\Helper\Data $helper,
|
\Retailcrm\Retailcrm\Helper\Data $helper,
|
||||||
array $data = []
|
array $data = []
|
||||||
) {
|
) {
|
||||||
parent::__construct($context, $data);
|
parent::__construct($context, $data);
|
||||||
$this->customer = $customerSession->getCustomer();
|
$this->customer = $customerSession->getCustomer();
|
||||||
|
$this->storeManager = $storeManager;
|
||||||
$this->storeResolver = $storeResolver;
|
$this->storeResolver = $storeResolver;
|
||||||
$this->helper = $helper;
|
$this->helper = $helper;
|
||||||
}
|
}
|
||||||
|
@ -60,7 +64,7 @@ EOT;
|
||||||
|
|
||||||
try {
|
try {
|
||||||
$siteKey = $this->helper->getSiteKey(
|
$siteKey = $this->helper->getSiteKey(
|
||||||
$this->_storeManager->getStore(
|
$this->storeManager->getStore(
|
||||||
$this->storeResolver->getCurrentStoreId()
|
$this->storeResolver->getCurrentStoreId()
|
||||||
)->getWebsiteId()
|
)->getWebsiteId()
|
||||||
);
|
);
|
||||||
|
|
|
@ -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,11 +161,11 @@ 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) {
|
||||||
$store = $this->storeManager->getStore($sites[$order['site']]);
|
$store = $this->storeManager->getStore($sites[$order['site']]);
|
||||||
$websiteId = $store->getWebsiteId();
|
$websiteId = $store->getWebsiteId();
|
||||||
} else {
|
} else {
|
||||||
|
@ -178,7 +178,7 @@ class Exchange
|
||||||
$customer->setWebsiteId($websiteId);
|
$customer->setWebsiteId($websiteId);
|
||||||
|
|
||||||
if (isset($order['customer']['externalId'])) {
|
if (isset($order['customer']['externalId'])) {
|
||||||
$customer = $this->customerRepository->getById($order['customer']['externalId']);
|
$customer->load($order['customer']['externalId']);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!$customer->getId()) {
|
if (!$customer->getId()) {
|
||||||
|
@ -190,7 +190,7 @@ class Exchange
|
||||||
->setEmail($order['email'])
|
->setEmail($order['email'])
|
||||||
->setPassword($order['email']);
|
->setPassword($order['email']);
|
||||||
try {
|
try {
|
||||||
$this->customerRepository->save($customer);
|
$customer->save();
|
||||||
} catch (\Exception $exception) {
|
} catch (\Exception $exception) {
|
||||||
$this->logger->writeRow($exception->getMessage());
|
$this->logger->writeRow($exception->getMessage());
|
||||||
}
|
}
|
||||||
|
@ -216,32 +216,9 @@ class Exchange
|
||||||
$quote->setCurrency();
|
$quote->setCurrency();
|
||||||
$quote->assignCustomer($customer); //Assign quote to customer
|
$quote->assignCustomer($customer); //Assign quote to customer
|
||||||
|
|
||||||
$manager = \Magento\Framework\App\ObjectManager::getInstance();
|
|
||||||
/** @var \Magento\Catalog\Api\ProductRepositoryInterface $productRepository */
|
|
||||||
$productRepository = $manager->create(\Magento\Catalog\Api\ProductRepositoryInterface::class);
|
|
||||||
|
|
||||||
$ditems = [];
|
|
||||||
foreach ($order['items'] as $item) {
|
|
||||||
if (!isset($ditems[$item['offer']['externalId']]['quantity'])) {
|
|
||||||
$ditems[$item['offer']['externalId']] = [
|
|
||||||
'quantity' => null,
|
|
||||||
'discountTotal' => null,
|
|
||||||
'initialPrice' => null,
|
|
||||||
'price_sum' => null,
|
|
||||||
'price_item' => null
|
|
||||||
];
|
|
||||||
}
|
|
||||||
|
|
||||||
$ditems[$item['offer']['externalId']]['quantity'] += $item['quantity'];
|
|
||||||
$ditems[$item['offer']['externalId']]['discountTotal'] += $item['quantity'] * $item['discountTotal'];
|
|
||||||
$ditems[$item['offer']['externalId']]['initialPrice'] = (float)$item['initialPrice'];
|
|
||||||
$ditems[$item['offer']['externalId']]['price_sum'] = $ditems[$item['offer']['externalId']]['initialPrice'] * $ditems[$item['offer']['externalId']]['quantity'] - $ditems[$item['offer']['externalId']]['discountTotal'];
|
|
||||||
$ditems[$item['offer']['externalId']]['price_item'] = $ditems[$item['offer']['externalId']]['price_sum'] / $ditems[$item['offer']['externalId']]['quantity'];
|
|
||||||
}
|
|
||||||
|
|
||||||
//add items in quote
|
//add items in quote
|
||||||
foreach ($ditems as $id =>$item) {
|
foreach ($order['items'] as $item) {
|
||||||
$product = $productRepository->getById($id,false, $store->getId(), false);
|
$product = $this->product->load($item['offer']['externalId']);
|
||||||
$product->setPrice($item['initialPrice']);
|
$product->setPrice($item['initialPrice']);
|
||||||
$quote->addProduct(
|
$quote->addProduct(
|
||||||
$product,
|
$product,
|
||||||
|
@ -251,8 +228,8 @@ class Exchange
|
||||||
|
|
||||||
$products = [];
|
$products = [];
|
||||||
|
|
||||||
foreach ($ditems as $id => $item) {
|
foreach ($order['items'] as $item) {
|
||||||
$products[$id] = ['product_id'=>$id,'qty' => $item['quantity']];
|
$products[$item['offer']['externalId']] = ['qty' => $item['quantity']];
|
||||||
}
|
}
|
||||||
|
|
||||||
$orderData = [
|
$orderData = [
|
||||||
|
@ -303,19 +280,17 @@ class Exchange
|
||||||
$quote->setPaymentMethod($payments[$paymentType]);
|
$quote->setPaymentMethod($payments[$paymentType]);
|
||||||
$quote->setInventoryProcessed(false);
|
$quote->setInventoryProcessed(false);
|
||||||
|
|
||||||
/** @var \Magento\Quote\Api\CartRepositoryInterface $quoteRepository */
|
$quote->save();
|
||||||
$quoteRepository = $manager->create(\Magento\Quote\Api\CartRepositoryInterface::class);
|
|
||||||
$quoteRepository->save($quote);
|
|
||||||
|
|
||||||
// Set Sales Order Payment
|
// Set Sales Order Payment
|
||||||
$quote->getPayment()->importData(['method' => $payments[$paymentType]]);
|
$quote->getPayment()->importData(['method' => $payments[$paymentType]]);
|
||||||
|
|
||||||
// Collect Totals & Save Quote
|
// Collect Totals & Save Quote
|
||||||
$quote->collectTotals();
|
$quote->collectTotals()->save();
|
||||||
$quoteRepository->save($quote);
|
|
||||||
|
|
||||||
// Create Order From Quote
|
// Create Order From Quote
|
||||||
$magentoOrder = $this->quoteManagement->submit($quote);
|
$magentoOrder = $this->quoteManagement->submit($quote);
|
||||||
|
|
||||||
$increment_id = $magentoOrder->getId();
|
$increment_id = $magentoOrder->getId();
|
||||||
|
|
||||||
$this->api->ordersFixExternalIds(
|
$this->api->ordersFixExternalIds(
|
||||||
|
@ -337,8 +312,8 @@ class Exchange
|
||||||
*/
|
*/
|
||||||
private function doCreateUp($order)
|
private function doCreateUp($order)
|
||||||
{
|
{
|
||||||
$manager = \Magento\Framework\App\ObjectManager::getInstance();
|
|
||||||
$this->logger->writeDump($order, 'doCreateUp');
|
$this->logger->writeDump($order, 'doCreateUp');
|
||||||
|
|
||||||
$response = $this->api->ordersGet($order['id'], $by = 'id');
|
$response = $this->api->ordersGet($order['id'], $by = 'id');
|
||||||
|
|
||||||
if (!$response->isSuccessful()) {
|
if (!$response->isSuccessful()) {
|
||||||
|
@ -349,13 +324,13 @@ 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();
|
||||||
|
|
||||||
if ($sites && in_array($order['site'], $sites)) {
|
if ($sites) {
|
||||||
$store = $this->storeManager->getStore($sites[$order['site']]);
|
$store = $this->storeManager->getStore($sites[$order['site']]);
|
||||||
$websiteId = $store->getWebsiteId();
|
$websiteId = $store->getWebsiteId();
|
||||||
} else {
|
} else {
|
||||||
|
@ -367,7 +342,7 @@ class Exchange
|
||||||
$customer->setWebsiteId($websiteId);
|
$customer->setWebsiteId($websiteId);
|
||||||
|
|
||||||
if (isset($order['customer']['externalId'])) {
|
if (isset($order['customer']['externalId'])) {
|
||||||
$customer = $this->customerRepository->getById($order['customer']['externalId']);
|
$customer->load($order['customer']['externalId']); // load customer by external id
|
||||||
}
|
}
|
||||||
|
|
||||||
//Create object of quote
|
//Create object of quote
|
||||||
|
@ -386,31 +361,9 @@ class Exchange
|
||||||
$quote->setCustomerIsGuest(1);
|
$quote->setCustomerIsGuest(1);
|
||||||
}
|
}
|
||||||
|
|
||||||
$ditems = [];
|
|
||||||
foreach ($order['items'] as $item) {
|
|
||||||
if (!isset($ditems[$item['offer']['externalId']]['quantity'])) {
|
|
||||||
$ditems[$item['offer']['externalId']] = [
|
|
||||||
'quantity' => null,
|
|
||||||
'discountTotal' => null,
|
|
||||||
'initialPrice' => null,
|
|
||||||
'price_sum' => null,
|
|
||||||
'price_item' => null
|
|
||||||
];
|
|
||||||
}
|
|
||||||
|
|
||||||
$ditems[$item['offer']['externalId']]['quantity'] += $item['quantity'];
|
|
||||||
$ditems[$item['offer']['externalId']]['discountTotal'] += $item['quantity'] * $item['discountTotal'];
|
|
||||||
$ditems[$item['offer']['externalId']]['initialPrice'] = (float)$item['initialPrice'];
|
|
||||||
$ditems[$item['offer']['externalId']]['price_sum'] = $ditems[$item['offer']['externalId']]['initialPrice'] * $ditems[$item['offer']['externalId']]['quantity'] - $ditems[$item['offer']['externalId']]['discountTotal'];
|
|
||||||
$ditems[$item['offer']['externalId']]['price_item'] = $ditems[$item['offer']['externalId']]['price_sum'] / $ditems[$item['offer']['externalId']]['quantity'];
|
|
||||||
}
|
|
||||||
|
|
||||||
/** @var \Magento\Catalog\Api\ProductRepositoryInterface $productRepository */
|
|
||||||
$productRepository = $manager->create(\Magento\Catalog\Api\ProductRepositoryInterface::class);
|
|
||||||
|
|
||||||
//add items in quote
|
//add items in quote
|
||||||
foreach ($ditems as $id => $item) {
|
foreach ($order['items'] as $item) {
|
||||||
$product = $productRepository->getById($id,false, $store->getId(), false);
|
$product = $this->product->load($item['offer']['externalId']);
|
||||||
$product->setPrice($item['initialPrice']);
|
$product->setPrice($item['initialPrice']);
|
||||||
$quote->addProduct(
|
$quote->addProduct(
|
||||||
$product,
|
$product,
|
||||||
|
@ -420,8 +373,8 @@ class Exchange
|
||||||
|
|
||||||
$products = [];
|
$products = [];
|
||||||
|
|
||||||
foreach ($ditems as $id => $item) {
|
foreach ($order['items'] as $item) {
|
||||||
$products[$id] = ['product_id'=>$id,'qty' => $item['quantity']];
|
$products[$item['offer']['externalId']] = ['qty' => $item['quantity']];
|
||||||
}
|
}
|
||||||
|
|
||||||
$orderData = [
|
$orderData = [
|
||||||
|
@ -482,20 +435,16 @@ class Exchange
|
||||||
];
|
];
|
||||||
|
|
||||||
$quote->setReservedOrderId($orderDataUp['increment_id']);
|
$quote->setReservedOrderId($orderDataUp['increment_id']);
|
||||||
/** @var \Magento\Quote\Api\CartRepositoryInterface $quoteRepository */
|
$quote->save();
|
||||||
$quoteRepository = $manager->create(\Magento\Quote\Api\CartRepositoryInterface::class);
|
|
||||||
$quoteRepository->save($quote);
|
|
||||||
|
|
||||||
// Set Sales Order Payment
|
// Set Sales Order Payment
|
||||||
$quote->getPayment()->importData(['method' => $payments[$paymentType]]);
|
$quote->getPayment()->importData(['method' => $payments[$paymentType]]);
|
||||||
|
|
||||||
// Collect Totals & Save Quote
|
// Collect Totals & Save Quote
|
||||||
$quote->collectTotals();
|
$quote->collectTotals()->save();
|
||||||
$quoteRepository->save($quote);
|
|
||||||
|
|
||||||
// Create Order From Quote
|
// Create Order From Quote
|
||||||
$magentoOrder = $this->quoteManagement->submit($quote, $orderDataUp);
|
$magentoOrder = $this->quoteManagement->submit($quote, $orderDataUp);
|
||||||
|
|
||||||
$oldOrder->setStatus('canceled')->save();
|
$oldOrder->setStatus('canceled')->save();
|
||||||
$increment_id = $magentoOrder->getId();
|
$increment_id = $magentoOrder->getId();
|
||||||
|
|
||||||
|
@ -520,7 +469,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']);
|
||||||
|
@ -559,11 +508,11 @@ class Exchange
|
||||||
|
|
||||||
foreach ($orderHistory as $change) {
|
foreach ($orderHistory as $change) {
|
||||||
$orderId = $change['order']['id'];
|
$orderId = $change['order']['id'];
|
||||||
|
|
||||||
$change['order'] = self::removeEmpty($change['order']);
|
$change['order'] = self::removeEmpty($change['order']);
|
||||||
|
|
||||||
if (isset($change['order']['items'])) {
|
if (isset($change['order']['items'])) {
|
||||||
$items = [];
|
$items = [];
|
||||||
|
|
||||||
foreach ($change['order']['items'] as $item) {
|
foreach ($change['order']['items'] as $item) {
|
||||||
if (isset($change['created'])) {
|
if (isset($change['created'])) {
|
||||||
$item['create'] = 1;
|
$item['create'] = 1;
|
||||||
|
@ -602,7 +551,7 @@ class Exchange
|
||||||
|
|
||||||
if (isset($change['item'])) {
|
if (isset($change['item'])) {
|
||||||
if (isset($orders[$change['order']['id']]['items'])
|
if (isset($orders[$change['order']['id']]['items'])
|
||||||
&& isset($orders[$change['order']['id']]['items'][$change['item']['id']])
|
&& $orders[$change['order']['id']]['items'][$change['item']['id']]
|
||||||
) {
|
) {
|
||||||
$orders[$change['order']['id']]['items'][$change['item']['id']] = array_merge(
|
$orders[$change['order']['id']]['items'][$change['item']['id']] = array_merge(
|
||||||
$orders[$change['order']['id']]['items'][$change['item']['id']],
|
$orders[$change['order']['id']]['items'][$change['item']['id']],
|
||||||
|
@ -627,6 +576,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;
|
||||||
}
|
}
|
||||||
|
|
|
@ -19,7 +19,8 @@ class Icml
|
||||||
private $resourceModelProduct;
|
private $resourceModelProduct;
|
||||||
private $searchCriteriaBuilder;
|
private $searchCriteriaBuilder;
|
||||||
private $productRepository;
|
private $productRepository;
|
||||||
private $dimensionFields = ['height', 'length', 'width'];
|
|
||||||
|
const DIMENSION_FIELDS = ['height', 'length', 'width'];
|
||||||
|
|
||||||
public function __construct(
|
public function __construct(
|
||||||
\Magento\Store\Model\StoreManagerInterface $manager,
|
\Magento\Store\Model\StoreManagerInterface $manager,
|
||||||
|
@ -443,7 +444,7 @@ class Icml
|
||||||
*/
|
*/
|
||||||
private function checkDimension($attrCode)
|
private function checkDimension($attrCode)
|
||||||
{
|
{
|
||||||
foreach ($this->dimensionFields as $dimensionField) {
|
foreach (self::DIMENSION_FIELDS as $dimensionField) {
|
||||||
if (mb_strpos($attrCode, $dimensionField) !== false) {
|
if (mb_strpos($attrCode, $dimensionField) !== false) {
|
||||||
return [$dimensionField => $attrCode];
|
return [$dimensionField => $attrCode];
|
||||||
}
|
}
|
||||||
|
|
|
@ -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) {
|
||||||
|
|
|
@ -69,6 +69,7 @@ class Customer implements CustomerManagerInterface
|
||||||
$billing = $order->getBillingAddress();
|
$billing = $order->getBillingAddress();
|
||||||
|
|
||||||
$preparedCustomer = [
|
$preparedCustomer = [
|
||||||
|
'externalId' => uniqid(),
|
||||||
'email' => $billing->getEmail(),
|
'email' => $billing->getEmail(),
|
||||||
'firstName' => $billing->getFirstname(),
|
'firstName' => $billing->getFirstname(),
|
||||||
'patronymic' => $billing->getMiddlename(),
|
'patronymic' => $billing->getMiddlename(),
|
||||||
|
@ -79,17 +80,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'),
|
||||||
|
@ -76,20 +72,22 @@ class Order implements \Retailcrm\Retailcrm\Api\OrderManagerInterface
|
||||||
]
|
]
|
||||||
];
|
];
|
||||||
|
|
||||||
$codeShop = $this->config->getValue('retailcrm/retailcrm_site/default');
|
|
||||||
|
|
||||||
if ($shippingAddress->getData('country_id')) {
|
if ($shippingAddress->getData('country_id')) {
|
||||||
$preparedOrder['countryIso'] = $shippingAddress->getData('country_id');
|
$preparedOrder['countryIso'] = $shippingAddress->getData('country_id');
|
||||||
}
|
}
|
||||||
|
|
||||||
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(
|
||||||
'externalId' => $codeShop.$order->getId(),
|
'retailcrm/retailcrm_payment/' . $order->getPayment()->getMethodInstance()->getCode()
|
||||||
|
),
|
||||||
|
'externalId' => $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(
|
||||||
|
|
|
@ -1,10 +1,6 @@
|
||||||
<?php
|
<?php
|
||||||
|
|
||||||
namespace Retailcrm\Retailcrm\Test\Unit\Block\Frontend;
|
class DaemonCollectorTest extends \PHPUnit\Framework\TestCase
|
||||||
|
|
||||||
use Retailcrm\Retailcrm\Test\TestCase;
|
|
||||||
|
|
||||||
class DaemonCollectorTest extends TestCase
|
|
||||||
{
|
{
|
||||||
private $unit;
|
private $unit;
|
||||||
private $customer;
|
private $customer;
|
||||||
|
@ -13,7 +9,8 @@ class DaemonCollectorTest extends TestCase
|
||||||
|
|
||||||
public function setUp()
|
public function setUp()
|
||||||
{
|
{
|
||||||
$context = $this->createMock(\Magento\Framework\View\Element\Template\Context::class);
|
$objectManager = new \Magento\Framework\TestFramework\Unit\Helper\ObjectManager($this);
|
||||||
|
$context = $objectManager->getObject(\Magento\Framework\View\Element\Template\Context::class);
|
||||||
$customerSession = $this->createMock(\Magento\Customer\Model\Session::class);
|
$customerSession = $this->createMock(\Magento\Customer\Model\Session::class);
|
||||||
$storeManager = $this->createMock(\Magento\Store\Model\StoreManager::class);
|
$storeManager = $this->createMock(\Magento\Store\Model\StoreManager::class);
|
||||||
$storeResolver = $this->createMock(\Magento\Store\Model\StoreResolver::class);
|
$storeResolver = $this->createMock(\Magento\Store\Model\StoreResolver::class);
|
||||||
|
@ -37,13 +34,10 @@ class DaemonCollectorTest extends TestCase
|
||||||
->method('getSiteKey')
|
->method('getSiteKey')
|
||||||
->willReturn(self::SITE_KEY);
|
->willReturn(self::SITE_KEY);
|
||||||
|
|
||||||
$context->expects($this->any())
|
|
||||||
->method('getStoreManager')
|
|
||||||
->willReturn($storeManager);
|
|
||||||
|
|
||||||
$this->unit = new \Retailcrm\Retailcrm\Block\Frontend\DaemonCollector(
|
$this->unit = new \Retailcrm\Retailcrm\Block\Frontend\DaemonCollector(
|
||||||
$context,
|
$context,
|
||||||
$customerSession,
|
$customerSession,
|
||||||
|
$storeManager,
|
||||||
$storeResolver,
|
$storeResolver,
|
||||||
$helper
|
$helper
|
||||||
);
|
);
|
||||||
|
|
|
@ -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,15 +2,11 @@
|
||||||
|
|
||||||
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;
|
||||||
private $unit;
|
private $unit;
|
||||||
private $mockOrder;
|
|
||||||
private $mockBillingAddress;
|
|
||||||
|
|
||||||
public function setUp()
|
public function setUp()
|
||||||
{
|
{
|
||||||
|
@ -33,59 +29,6 @@ class CustomerTest extends TestCase
|
||||||
'getAddressesCollection'
|
'getAddressesCollection'
|
||||||
])
|
])
|
||||||
->getMock();
|
->getMock();
|
||||||
|
|
||||||
$this->mockOrder = $this->getMockBuilder(\Magento\Sales\Model\Order::class)
|
|
||||||
->disableOriginalConstructor()
|
|
||||||
->setMethods([
|
|
||||||
'getBillingAddress',
|
|
||||||
])
|
|
||||||
->getMock();
|
|
||||||
|
|
||||||
$this->mockBillingAddress = $this->getMockBuilder(\Magento\Customer\Model\Address\AddressModelInterface::class)
|
|
||||||
->disableOriginalConstructor()
|
|
||||||
->setMethods([
|
|
||||||
'getTelephone',
|
|
||||||
'getEmail',
|
|
||||||
'getData',
|
|
||||||
'getFirstname',
|
|
||||||
'getMiddlename',
|
|
||||||
'getLastname',
|
|
||||||
'getCountryId',
|
|
||||||
'getPostcode',
|
|
||||||
'getRegion',
|
|
||||||
'getCity',
|
|
||||||
'getStreet'
|
|
||||||
])
|
|
||||||
->getMockForAbstractClass();
|
|
||||||
|
|
||||||
$this->unit = new \Retailcrm\Retailcrm\Model\Service\Customer(
|
|
||||||
$this->mockData
|
|
||||||
);
|
|
||||||
}
|
|
||||||
|
|
||||||
public function testPrepareCustomerFromOrder()
|
|
||||||
{
|
|
||||||
$this->mockOrder->expects($this->any())
|
|
||||||
->method('getBillingAddress')
|
|
||||||
->willReturn($this->mockBillingAddress);
|
|
||||||
|
|
||||||
$result = $this->unit->prepareCustomerFromOrder($this->mockOrder);
|
|
||||||
|
|
||||||
$this->assertNotEmpty($result);
|
|
||||||
$this->assertInternalType('array', $result);
|
|
||||||
$this->assertArrayNotHasKey('externalId', $result);
|
|
||||||
$this->assertArrayHasKey('email', $result);
|
|
||||||
$this->assertArrayHasKey('firstName', $result);
|
|
||||||
$this->assertArrayHasKey('lastName', $result);
|
|
||||||
$this->assertArrayHasKey('patronymic', $result);
|
|
||||||
$this->assertArrayHasKey('address', $result);
|
|
||||||
$this->assertInternalType('array', $result['address']);
|
|
||||||
$this->assertArrayHasKey('countryIso', $result['address']);
|
|
||||||
$this->assertArrayHasKey('index', $result['address']);
|
|
||||||
$this->assertArrayHasKey('region', $result['address']);
|
|
||||||
$this->assertArrayHasKey('city', $result['address']);
|
|
||||||
$this->assertArrayHasKey('street', $result['address']);
|
|
||||||
$this->assertArrayHasKey('text', $result['address']);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -164,6 +107,10 @@ class CustomerTest extends TestCase
|
||||||
->method('getAddressesCollection')
|
->method('getAddressesCollection')
|
||||||
->willReturn([$mockAddress]);
|
->willReturn([$mockAddress]);
|
||||||
|
|
||||||
|
$this->unit = new \Retailcrm\Retailcrm\Model\Service\Customer(
|
||||||
|
$this->mockData
|
||||||
|
);
|
||||||
|
|
||||||
$result = $this->unit->process($this->mockCustomer);
|
$result = $this->unit->process($this->mockCustomer);
|
||||||
|
|
||||||
$this->assertNotEmpty($result);
|
$this->assertNotEmpty($result);
|
||||||
|
|
|
@ -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.0",
|
||||||
"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