Save config dinamic fields
* save config dinamic fields * update test
This commit is contained in:
parent
ae03c8c881
commit
97a9e8b27c
3
.gitignore
vendored
3
.gitignore
vendored
@ -1 +1,2 @@
|
|||||||
/nbproject/private/
|
/nbproject/private/
|
||||||
|
.idea
|
||||||
|
218
.travis.yml
218
.travis.yml
@ -1,6 +1,8 @@
|
|||||||
|
os: linux
|
||||||
|
dist: trusty
|
||||||
language: php
|
language: php
|
||||||
|
|
||||||
sudo: false
|
if: tag IS blank
|
||||||
|
|
||||||
env:
|
env:
|
||||||
global:
|
global:
|
||||||
@ -13,34 +15,210 @@ env:
|
|||||||
- ADMIN_USER=admin
|
- ADMIN_USER=admin
|
||||||
- ADMIN_PASS=admin123
|
- ADMIN_PASS=admin123
|
||||||
|
|
||||||
matrix:
|
stages:
|
||||||
|
- test
|
||||||
|
|
||||||
|
jobs:
|
||||||
include:
|
include:
|
||||||
|
- php: 7.0
|
||||||
|
env: BRANCH=2.0.2
|
||||||
|
|
||||||
- php: 7.0
|
- php: 7.0
|
||||||
env: BRANCH=2.2.5
|
env: BRANCH=2.0.4
|
||||||
- php: 7.1
|
|
||||||
env: BRANCH=2.2.5
|
|
||||||
|
|
||||||
- php: 7.0
|
- php: 7.0
|
||||||
env: BRANCH=2.2.6
|
env: BRANCH=2.0.5
|
||||||
- php: 7.1
|
|
||||||
env: BRANCH=2.2.6
|
|
||||||
|
|
||||||
- php: 7.0
|
- php: 7.0
|
||||||
env: BRANCH=2.2.7
|
env: BRANCH=2.0.6
|
||||||
- php: 7.1
|
|
||||||
env: BRANCH=2.2.7
|
|
||||||
|
|
||||||
- php: 7.0
|
- php: 7.0
|
||||||
env: BRANCH=2.2.8
|
env: BRANCH=2.0.7
|
||||||
- php: 7.1
|
|
||||||
env: BRANCH=2.2.8
|
- php: 7.0
|
||||||
|
env: BRANCH=2.0.8
|
||||||
|
|
||||||
|
- php: 7.0
|
||||||
|
env: BRANCH=2.0.9
|
||||||
|
|
||||||
|
- php: 7.0
|
||||||
|
env: BRANCH=2.0.10
|
||||||
|
|
||||||
|
- php: 7.0
|
||||||
|
env: BRANCH=2.0.11
|
||||||
|
|
||||||
|
- php: 7.0
|
||||||
|
env: BRANCH=2.0.12
|
||||||
|
|
||||||
|
- php: 7.0
|
||||||
|
env: BRANCH=2.0.13
|
||||||
|
|
||||||
|
- php: 7.0
|
||||||
|
env: BRANCH=2.0.14
|
||||||
|
|
||||||
|
- php: 7.0
|
||||||
|
env: BRANCH=2.0.15
|
||||||
|
|
||||||
|
- php: 7.0
|
||||||
|
env: BRANCH=2.0.16
|
||||||
|
|
||||||
|
- php: 7.0
|
||||||
|
env: BRANCH=2.0.17
|
||||||
|
|
||||||
|
- php: 7.0
|
||||||
|
env: BRANCH=2.0.18
|
||||||
|
|
||||||
|
- php: 7.0
|
||||||
|
env: BRANCH=2.1.0
|
||||||
|
|
||||||
|
- php: 7.0
|
||||||
|
env: BRANCH=2.1.1
|
||||||
|
|
||||||
|
- php: 7.0
|
||||||
|
env: BRANCH=2.1.2
|
||||||
|
|
||||||
|
- php: 7.0
|
||||||
|
env: BRANCH=2.1.3
|
||||||
|
|
||||||
|
- php: 7.0
|
||||||
|
env: BRANCH=2.1.4
|
||||||
|
|
||||||
|
- php: 7.0
|
||||||
|
env: BRANCH=2.1.5
|
||||||
|
|
||||||
|
- php: 7.0
|
||||||
|
env: BRANCH=2.1.6
|
||||||
|
|
||||||
|
- php: 7.0
|
||||||
|
env: BRANCH=2.1.7
|
||||||
|
|
||||||
|
- php: 7.0
|
||||||
|
env: BRANCH=2.1.8
|
||||||
|
|
||||||
|
- php: 7.0
|
||||||
|
env: BRANCH=2.1.9
|
||||||
|
|
||||||
|
- php: 7.0
|
||||||
|
env: BRANCH=2.1.10
|
||||||
|
|
||||||
|
- php: 7.0
|
||||||
|
env: BRANCH=2.1.11
|
||||||
|
|
||||||
|
- php: 7.0
|
||||||
|
env: BRANCH=2.1.12
|
||||||
|
|
||||||
|
- php: 7.0
|
||||||
|
env: BRANCH=2.1.13
|
||||||
|
|
||||||
|
- php: 7.0
|
||||||
|
env: BRANCH=2.1.14
|
||||||
|
|
||||||
|
- php: 7.0
|
||||||
|
env: BRANCH=2.1.15
|
||||||
|
|
||||||
|
- php: 7.0
|
||||||
|
env: BRANCH=2.1.16
|
||||||
|
- php: 7.1
|
||||||
|
env: BRANCH=2.1.16
|
||||||
|
|
||||||
|
- php: 7.0
|
||||||
|
env: BRANCH=2.1.17
|
||||||
|
- php: 7.1
|
||||||
|
env: BRANCH=2.1.17
|
||||||
|
|
||||||
|
- php: 7.0
|
||||||
|
env: BRANCH=2.1.18
|
||||||
|
- php: 7.1
|
||||||
|
env: BRANCH=2.1.18
|
||||||
|
|
||||||
|
- php: 7.0
|
||||||
|
env: BRANCH=2.2.0
|
||||||
|
- php: 7.1
|
||||||
|
env: BRANCH=2.2.0
|
||||||
|
|
||||||
|
- php: 7.0
|
||||||
|
env: BRANCH=2.2.1
|
||||||
|
- php: 7.1
|
||||||
|
env: BRANCH=2.2.1
|
||||||
|
|
||||||
|
- php: 7.0
|
||||||
|
env: BRANCH=2.2.2
|
||||||
|
- php: 7.1
|
||||||
|
env: BRANCH=2.2.2
|
||||||
|
|
||||||
|
- php: 7.0
|
||||||
|
env: BRANCH=2.2.3
|
||||||
|
- php: 7.1
|
||||||
|
env: BRANCH=2.2.3
|
||||||
|
|
||||||
|
- php: 7.0
|
||||||
|
env: BRANCH=2.2.4
|
||||||
|
- php: 7.1
|
||||||
|
env: BRANCH=2.2.4
|
||||||
|
|
||||||
|
- php: 7.0
|
||||||
|
env: BRANCH=2.2.5
|
||||||
|
- php: 7.1
|
||||||
|
env: BRANCH=2.2.5
|
||||||
|
|
||||||
|
- php: 7.0
|
||||||
|
env: BRANCH=2.2.6
|
||||||
|
- php: 7.1
|
||||||
|
env: BRANCH=2.2.6
|
||||||
|
|
||||||
|
- php: 7.0
|
||||||
|
env: BRANCH=2.2.7
|
||||||
|
- php: 7.1
|
||||||
|
env: BRANCH=2.2.7
|
||||||
|
|
||||||
|
- php: 7.0
|
||||||
|
env: BRANCH=2.2.8
|
||||||
|
- php: 7.1
|
||||||
|
env: BRANCH=2.2.8
|
||||||
|
|
||||||
|
- php: 7.0
|
||||||
|
env: BRANCH=2.2.9
|
||||||
|
- php: 7.1
|
||||||
|
env: BRANCH=2.2.9
|
||||||
|
|
||||||
|
- php: 7.0
|
||||||
|
env: BRANCH=2.2.10
|
||||||
|
- php: 7.1
|
||||||
|
env: BRANCH=2.2.10
|
||||||
|
- php: 7.2
|
||||||
|
env: BRANCH=2.2.10
|
||||||
|
|
||||||
|
- php: 7.1
|
||||||
|
env: BRANCH=2.3.0
|
||||||
|
- php: 7.2
|
||||||
|
env: BRANCH=2.3.0
|
||||||
|
|
||||||
|
- php: 7.1
|
||||||
|
env: BRANCH=2.3.1
|
||||||
|
- php: 7.2
|
||||||
|
env: BRANCH=2.3.1
|
||||||
|
|
||||||
|
- php: 7.1
|
||||||
|
env: BRANCH=2.3.2
|
||||||
|
- php: 7.2
|
||||||
|
env: BRANCH=2.3.2
|
||||||
|
|
||||||
|
- php: 7.1
|
||||||
|
env: BRANCH=2.3.3
|
||||||
|
- php: 7.2
|
||||||
|
env: BRANCH=2.3.3
|
||||||
|
- php: 7.3
|
||||||
|
env: BRANCH=2.3.3
|
||||||
|
|
||||||
|
- php: 7.2
|
||||||
|
env: BRANCH=2.3.4
|
||||||
|
- php: 7.3
|
||||||
|
env: BRANCH=2.3.4
|
||||||
|
|
||||||
before_script:
|
before_script:
|
||||||
- bash bin/install.sh
|
- bash bin/install.sh
|
||||||
|
|
||||||
script:
|
script: make ci
|
||||||
- bash bin/script.sh
|
|
||||||
|
|
||||||
# deploy:
|
# deploy:
|
||||||
# skip_cleanup: true
|
# skip_cleanup: true
|
||||||
|
4
Makefile
4
Makefile
@ -1,6 +1,7 @@
|
|||||||
FILE = $(TRAVIS_BUILD_DIR)/VERSION
|
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 = $(TRAVIS_BUILD_DIR)/../magento2
|
||||||
|
|
||||||
all: build_archive send_to_ftp delete_archive
|
all: build_archive send_to_ftp delete_archive
|
||||||
|
|
||||||
@ -12,3 +13,6 @@ send_to_ftp:
|
|||||||
|
|
||||||
delete_archive:
|
delete_archive:
|
||||||
rm -f $(ARCHIVE_NAME)
|
rm -f $(ARCHIVE_NAME)
|
||||||
|
|
||||||
|
ci:
|
||||||
|
php $(MAGE_ROOT)/vendor/phpunit/phpunit/phpunit -c $(MAGE_ROOT)/dev/tests/unit/phpunit.xml.dist $(MAGE_ROOT)/app/code/Retailcrm/Retailcrm/Test/Unit
|
||||||
|
@ -15,7 +15,23 @@ 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
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1,9 +0,0 @@
|
|||||||
#!/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
|
|
@ -116,7 +116,7 @@ class Payment extends \Magento\Config\Block\System\Config\Form\Fieldset
|
|||||||
return $defaultValues;
|
return $defaultValues;
|
||||||
}
|
}
|
||||||
|
|
||||||
if ($response->isSuccessful()) {
|
if (isset($response['paymentTypes']) && $response->isSuccessful()) {
|
||||||
$paymentsTypes = $response['paymentTypes'];
|
$paymentsTypes = $response['paymentTypes'];
|
||||||
} else {
|
} else {
|
||||||
return $defaultValues;
|
return $defaultValues;
|
||||||
|
@ -0,0 +1,95 @@
|
|||||||
|
<?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,13 +117,17 @@ class Shipping extends \Magento\Config\Block\System\Config\Form\Fieldset
|
|||||||
|
|
||||||
$values = [];
|
$values = [];
|
||||||
|
|
||||||
$response = $this->client->deliveryTypesList();
|
try {
|
||||||
|
$response = $this->client->deliveryTypesList();
|
||||||
|
} catch (\Exception $exception) {
|
||||||
|
return $defaultValues;
|
||||||
|
}
|
||||||
|
|
||||||
if ($response === false) {
|
if ($response === false) {
|
||||||
return $defaultValues;
|
return $defaultValues;
|
||||||
}
|
}
|
||||||
|
|
||||||
if ($response->isSuccessful()) {
|
if (isset($response['deliveryTypes']) && $response->isSuccessful()) {
|
||||||
$deliveryTypes = $response['deliveryTypes'];
|
$deliveryTypes = $response['deliveryTypes'];
|
||||||
} else {
|
} else {
|
||||||
return $defaultValues;
|
return $defaultValues;
|
||||||
|
@ -0,0 +1,95 @@
|
|||||||
|
<?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,13 +109,17 @@ class Site extends \Magento\Config\Block\System\Config\Form\Fieldset
|
|||||||
|
|
||||||
$values = [];
|
$values = [];
|
||||||
|
|
||||||
$response = $this->client->sitesList();
|
try {
|
||||||
|
$response = $this->client->sitesList();
|
||||||
|
} catch (\Exception $exception) {
|
||||||
|
return $defaultValues;
|
||||||
|
}
|
||||||
|
|
||||||
if ($response === false) {
|
if ($response === false) {
|
||||||
return $defaultValues;
|
return $defaultValues;
|
||||||
}
|
}
|
||||||
|
|
||||||
if ($response->isSuccessful()) {
|
if (isset($response['sites']) && $response->isSuccessful()) {
|
||||||
$sites = $response['sites'];
|
$sites = $response['sites'];
|
||||||
} else {
|
} else {
|
||||||
return $defaultValues;
|
return $defaultValues;
|
||||||
|
@ -115,13 +115,17 @@ class Sites extends \Magento\Config\Block\System\Config\Form\Fieldset
|
|||||||
|
|
||||||
$values = [];
|
$values = [];
|
||||||
|
|
||||||
$response = $this->client->sitesList();
|
try {
|
||||||
|
$response = $this->client->sitesList();
|
||||||
|
} catch (\Exception $exception) {
|
||||||
|
return $defaultValues;
|
||||||
|
}
|
||||||
|
|
||||||
if ($response === false) {
|
if ($response === false) {
|
||||||
return $defaultValues;
|
return $defaultValues;
|
||||||
}
|
}
|
||||||
|
|
||||||
if ($response->isSuccessful()) {
|
if (isset($response['sites']) && $response->isSuccessful()) {
|
||||||
$sites = $response['sites'];
|
$sites = $response['sites'];
|
||||||
} else {
|
} else {
|
||||||
return $defaultValues;
|
return $defaultValues;
|
||||||
|
@ -111,13 +111,17 @@ class Status extends \Magento\Config\Block\System\Config\Form\Fieldset
|
|||||||
|
|
||||||
$values = [];
|
$values = [];
|
||||||
|
|
||||||
$response = $this->client->statusesList();
|
try {
|
||||||
|
$response = $this->client->statusesList();
|
||||||
|
} catch (\Exception $exception) {
|
||||||
|
return $defaultValues;
|
||||||
|
}
|
||||||
|
|
||||||
if ($response === false) {
|
if ($response === false) {
|
||||||
return $defaultValues;
|
return $defaultValues;
|
||||||
}
|
}
|
||||||
|
|
||||||
if ($response->isSuccessful()) {
|
if (isset($response['statuses']) && $response->isSuccessful()) {
|
||||||
$statuses = $response['statuses'];
|
$statuses = $response['statuses'];
|
||||||
} else {
|
} else {
|
||||||
return $defaultValues;
|
return $defaultValues;
|
||||||
|
@ -0,0 +1,95 @@
|
|||||||
|
<?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);
|
||||||
|
}
|
||||||
|
}
|
@ -206,4 +206,63 @@ 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);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
71
src/Model/Config/Backend/PaymentCms.php
Normal file
71
src/Model/Config/Backend/PaymentCms.php
Normal file
@ -0,0 +1,71 @@
|
|||||||
|
<?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();
|
||||||
|
}
|
||||||
|
}
|
75
src/Model/Config/Backend/PaymentCrm.php
Normal file
75
src/Model/Config/Backend/PaymentCrm.php
Normal file
@ -0,0 +1,75 @@
|
|||||||
|
<?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();
|
||||||
|
}
|
||||||
|
}
|
72
src/Model/Config/Backend/ShippingCms.php
Normal file
72
src/Model/Config/Backend/ShippingCms.php
Normal file
@ -0,0 +1,72 @@
|
|||||||
|
<?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();
|
||||||
|
}
|
||||||
|
}
|
74
src/Model/Config/Backend/ShippingCrm.php
Normal file
74
src/Model/Config/Backend/ShippingCrm.php
Normal file
@ -0,0 +1,74 @@
|
|||||||
|
<?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();
|
||||||
|
}
|
||||||
|
}
|
71
src/Model/Config/Backend/StatusCms.php
Normal file
71
src/Model/Config/Backend/StatusCms.php
Normal file
@ -0,0 +1,71 @@
|
|||||||
|
<?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();
|
||||||
|
}
|
||||||
|
}
|
75
src/Model/Config/Backend/StatusCrm.php
Normal file
75
src/Model/Config/Backend/StatusCrm.php
Normal file
@ -0,0 +1,75 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
namespace Retailcrm\Retailcrm\Model\Config\Backend;
|
||||||
|
|
||||||
|
class StatusCrm extends \Magento\Framework\View\Element\Html\Select
|
||||||
|
{
|
||||||
|
/**
|
||||||
|
* @var \Retailcrm\Retailcrm\Helper\Proxy
|
||||||
|
*/
|
||||||
|
private $client;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @var \Retailcrm\Retailcrm\Model\Logger\Logger
|
||||||
|
*/
|
||||||
|
private $logger;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Activation constructor.
|
||||||
|
*
|
||||||
|
* @param \Magento\Framework\View\Element\Context $context
|
||||||
|
* @param array $data
|
||||||
|
*/
|
||||||
|
public function __construct(
|
||||||
|
\Magento\Framework\View\Element\Context $context,
|
||||||
|
\Retailcrm\Retailcrm\Helper\Proxy $client,
|
||||||
|
\Retailcrm\Retailcrm\Model\Logger\Logger $logger,
|
||||||
|
array $data = []
|
||||||
|
) {
|
||||||
|
parent::__construct($context, $data);
|
||||||
|
|
||||||
|
$this->client = $client;
|
||||||
|
$this->logger = $logger;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param string $value
|
||||||
|
* @return Magently\Tutorial\Block\Adminhtml\Form\Field\Activation
|
||||||
|
*/
|
||||||
|
public function setInputName($value)
|
||||||
|
{
|
||||||
|
return $this->setName($value);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Parse to html.
|
||||||
|
*
|
||||||
|
* @return mixed
|
||||||
|
*/
|
||||||
|
public function _toHtml()
|
||||||
|
{
|
||||||
|
if (!$this->getOptions()) {
|
||||||
|
$statuses = array();
|
||||||
|
|
||||||
|
try {
|
||||||
|
$response = $this->client->statusesList();
|
||||||
|
} catch (\Exception $exception) {
|
||||||
|
$this->logger->writeRow($exception->getMessage());
|
||||||
|
}
|
||||||
|
|
||||||
|
if (isset($response) && $response->isSuccessful()) {
|
||||||
|
$statuses = $response['statuses'];
|
||||||
|
}
|
||||||
|
|
||||||
|
$this->addOption( 'null', "not selected");
|
||||||
|
if ($statuses) {
|
||||||
|
foreach ($statuses as $status) {
|
||||||
|
$this->addOption($status['code'], $status['name']);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
return parent::_toHtml();
|
||||||
|
}
|
||||||
|
}
|
@ -161,8 +161,8 @@ class Exchange
|
|||||||
{
|
{
|
||||||
$this->logger->writeDump($order, 'doCreate');
|
$this->logger->writeDump($order, 'doCreate');
|
||||||
|
|
||||||
$payments = $this->config->getValue('retailcrm/retailcrm_payment');
|
$payments = $this->helper->getConfigPayments();
|
||||||
$shippings = $this->config->getValue('retailcrm/retailcrm_shipping');
|
$shippings = $this->helper->getCongigShipping();
|
||||||
$sites = $this->helper->getMappingSites();
|
$sites = $this->helper->getMappingSites();
|
||||||
|
|
||||||
if ($sites && in_array($order['site'], $sites)) {
|
if ($sites && in_array($order['site'], $sites)) {
|
||||||
@ -242,7 +242,7 @@ class Exchange
|
|||||||
//add items in quote
|
//add items in quote
|
||||||
foreach ($ditems as $id =>$item) {
|
foreach ($ditems as $id =>$item) {
|
||||||
$product = $productRepository->getById($id,false, $store->getId(), false);
|
$product = $productRepository->getById($id,false, $store->getId(), false);
|
||||||
$product->setPrice($item['price_item']);
|
$product->setPrice($item['initialPrice']);
|
||||||
$quote->addProduct(
|
$quote->addProduct(
|
||||||
$product,
|
$product,
|
||||||
(int)$item['quantity']
|
(int)$item['quantity']
|
||||||
@ -349,8 +349,8 @@ class Exchange
|
|||||||
$order = $response['order'];
|
$order = $response['order'];
|
||||||
}
|
}
|
||||||
|
|
||||||
$payments = $this->config->getValue('retailcrm/retailcrm_payment');
|
$payments = $this->helper->getConfigPayments();
|
||||||
$shippings = $this->config->getValue('retailcrm/retailcrm_shipping');
|
$shippings = $this->helper->getCongigShipping();
|
||||||
|
|
||||||
$region = $this->regionFactory->create();
|
$region = $this->regionFactory->create();
|
||||||
$sites = $this->helper->getMappingSites();
|
$sites = $this->helper->getMappingSites();
|
||||||
@ -411,7 +411,7 @@ class Exchange
|
|||||||
//add items in quote
|
//add items in quote
|
||||||
foreach ($ditems as $id => $item) {
|
foreach ($ditems as $id => $item) {
|
||||||
$product = $productRepository->getById($id,false, $store->getId(), false);
|
$product = $productRepository->getById($id,false, $store->getId(), false);
|
||||||
$product->setPrice($item['price_item']);
|
$product->setPrice($item['initialPrice']);
|
||||||
$quote->addProduct(
|
$quote->addProduct(
|
||||||
$product,
|
$product,
|
||||||
(int)$item['quantity']
|
(int)$item['quantity']
|
||||||
@ -520,7 +520,7 @@ class Exchange
|
|||||||
{
|
{
|
||||||
$this->logger->writeDump($order, 'doUpdate');
|
$this->logger->writeDump($order, 'doUpdate');
|
||||||
|
|
||||||
$Status = $this->config->getValue('retailcrm/retailcrm_status');
|
$Status = $this->helper->getCongigStatus();
|
||||||
$Status = array_flip(array_filter($Status));
|
$Status = array_flip(array_filter($Status));
|
||||||
|
|
||||||
$magentoOrder = $this->order->load($order['externalId']);
|
$magentoOrder = $this->order->load($order['externalId']);
|
||||||
|
@ -53,9 +53,11 @@ 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' => $this->config->getValue('retailcrm/retailcrm_status/' . $order->getStatus())
|
'status' => $statusList[$order->getStatus()]
|
||||||
];
|
];
|
||||||
|
|
||||||
if ($order->getBaseTotalDue() == 0) {
|
if ($order->getBaseTotalDue() == 0) {
|
||||||
|
@ -3,6 +3,7 @@
|
|||||||
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
|
||||||
{
|
{
|
||||||
@ -110,9 +111,15 @@ 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,6 +37,10 @@ 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(),
|
||||||
@ -46,10 +50,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' => $this->config->getValue('retailcrm/retailcrm_status/' . $order->getStatus()),
|
'status' => $statusList[$order->getStatus()],
|
||||||
'items' => $products,
|
'items' => $products,
|
||||||
'delivery' => [
|
'delivery' => [
|
||||||
'code' => $this->config->getValue('retailcrm/retailcrm_shipping/' . $shipping),
|
'code' => $shipList[$shipping],
|
||||||
'cost' => $order->getShippingAmount(),
|
'cost' => $order->getShippingAmount(),
|
||||||
'address' => [
|
'address' => [
|
||||||
'index' => $shippingAddress->getData('postcode'),
|
'index' => $shippingAddress->getData('postcode'),
|
||||||
@ -80,15 +84,11 @@ class Order implements \Retailcrm\Retailcrm\Api\OrderManagerInterface
|
|||||||
|
|
||||||
if ($this->helper->getGeneralSettings('api_version') == 'v4') {
|
if ($this->helper->getGeneralSettings('api_version') == 'v4') {
|
||||||
$preparedOrder['discount'] = abs($order->getDiscountAmount());
|
$preparedOrder['discount'] = abs($order->getDiscountAmount());
|
||||||
$preparedOrder['paymentType'] = $this->config->getValue(
|
$preparedOrder['paymentType'] = $paymentList[$order->getPayment()->getMethodInstance()->getCode()];
|
||||||
'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' => $this->config->getValue(
|
'type'=> $paymentList[$order->getPayment()->getMethodInstance()->getCode()],
|
||||||
'retailcrm/retailcrm_payment/' . $order->getPayment()->getMethodInstance()->getCode()
|
|
||||||
),
|
|
||||||
'externalId' => $codeShop.$order->getId(),
|
'externalId' => $codeShop.$order->getId(),
|
||||||
'order' => [
|
'order' => [
|
||||||
'externalId' => $order->getId(),
|
'externalId' => $order->getId(),
|
||||||
|
@ -2,7 +2,9 @@
|
|||||||
|
|
||||||
namespace Retailcrm\Retailcrm\Test\Helpers;
|
namespace Retailcrm\Retailcrm\Test\Helpers;
|
||||||
|
|
||||||
class FieldsetTest extends \PHPUnit\Framework\TestCase
|
use Retailcrm\Retailcrm\Test\TestCase;
|
||||||
|
|
||||||
|
class FieldsetTest extends TestCase
|
||||||
{
|
{
|
||||||
protected $elementMock;
|
protected $elementMock;
|
||||||
protected $authSessionMock;
|
protected $authSessionMock;
|
||||||
@ -100,7 +102,7 @@ class FieldsetTest extends \PHPUnit\Framework\TestCase
|
|||||||
\Magento\Config\Block\System\Config\Form::class,
|
\Magento\Config\Block\System\Config\Form::class,
|
||||||
['getElements', 'getRequest']
|
['getElements', '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);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
58
src/Test/TestCase.php
Normal file
58
src/Test/TestCase.php
Normal file
@ -0,0 +1,58 @@
|
|||||||
|
<?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();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
@ -2,7 +2,9 @@
|
|||||||
|
|
||||||
namespace Retailcrm\Retailcrm\Test\Unit\Block\Frontend;
|
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;
|
||||||
|
@ -2,7 +2,9 @@
|
|||||||
|
|
||||||
namespace Retailcrm\Retailcrm\Test\Unit\Model\Observer;
|
namespace Retailcrm\Retailcrm\Test\Unit\Model\Observer;
|
||||||
|
|
||||||
class CustomerTest extends \PHPUnit\Framework\TestCase
|
use Retailcrm\Retailcrm\Test\TestCase;
|
||||||
|
|
||||||
|
class CustomerTest extends TestCase
|
||||||
{
|
{
|
||||||
private $mockApi;
|
private $mockApi;
|
||||||
private $mockResponse;
|
private $mockResponse;
|
||||||
|
@ -2,10 +2,12 @@
|
|||||||
|
|
||||||
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 \PHPUnit\Framework\TestCase
|
class OrderCreateTest extends TestCase
|
||||||
{
|
{
|
||||||
private $unit;
|
private $unit;
|
||||||
private $mockEvent;
|
private $mockEvent;
|
||||||
|
@ -2,7 +2,9 @@
|
|||||||
|
|
||||||
namespace Retailcrm\Retailcrm\Test\Unit\Observer;
|
namespace Retailcrm\Retailcrm\Test\Unit\Observer;
|
||||||
|
|
||||||
class OrderUpdateTest extends \PHPUnit\Framework\TestCase
|
use Retailcrm\Retailcrm\Test\TestCase;
|
||||||
|
|
||||||
|
class OrderUpdateTest extends TestCase
|
||||||
{
|
{
|
||||||
private $unit;
|
private $unit;
|
||||||
private $objectManager;
|
private $objectManager;
|
||||||
|
@ -2,7 +2,9 @@
|
|||||||
|
|
||||||
namespace Retailcrm\Retailcrm\Test\Unit\Model\Service;
|
namespace Retailcrm\Retailcrm\Test\Unit\Model\Service;
|
||||||
|
|
||||||
class CustomerTest extends \PHPUnit\Framework\TestCase
|
use Retailcrm\Retailcrm\Test\TestCase;
|
||||||
|
|
||||||
|
class CustomerTest extends TestCase
|
||||||
{
|
{
|
||||||
private $mockData;
|
private $mockData;
|
||||||
private $mockCustomer;
|
private $mockCustomer;
|
||||||
|
@ -2,7 +2,9 @@
|
|||||||
|
|
||||||
namespace Retailcrm\Retailcrm\Test\Unit\Model\Service;
|
namespace Retailcrm\Retailcrm\Test\Unit\Model\Service;
|
||||||
|
|
||||||
class IntegrationModuleTest extends \PHPUnit\Framework\TestCase
|
use Retailcrm\Retailcrm\Test\TestCase;
|
||||||
|
|
||||||
|
class IntegrationModuleTest extends TestCase
|
||||||
{
|
{
|
||||||
private $mockResourceConfig;
|
private $mockResourceConfig;
|
||||||
private $mockApiClient;
|
private $mockApiClient;
|
||||||
|
@ -2,7 +2,9 @@
|
|||||||
|
|
||||||
namespace Retailcrm\Retailcrm\Test\Unit\Model\Service;
|
namespace Retailcrm\Retailcrm\Test\Unit\Model\Service;
|
||||||
|
|
||||||
class InventoriesUploadTest extends \PHPUnit\Framework\TestCase
|
use Retailcrm\Retailcrm\Test\TestCase;
|
||||||
|
|
||||||
|
class InventoriesUploadTest extends TestCase
|
||||||
{
|
{
|
||||||
private $mockApi;
|
private $mockApi;
|
||||||
private $mockProductRepository;
|
private $mockProductRepository;
|
||||||
@ -18,12 +20,12 @@ class InventoriesUploadTest extends \PHPUnit\Framework\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'])
|
||||||
@ -47,6 +49,7 @@ class InventoriesUploadTest extends \PHPUnit\Framework\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')
|
||||||
@ -88,9 +91,9 @@ class InventoriesUploadTest extends \PHPUnit\Framework\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']
|
||||||
@ -100,7 +103,7 @@ class InventoriesUploadTest extends \PHPUnit\Framework\TestCase
|
|||||||
)
|
)
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
private function getApiInventories()
|
private function getApiInventories()
|
||||||
{
|
{
|
||||||
return array(
|
return array(
|
||||||
|
@ -2,7 +2,9 @@
|
|||||||
|
|
||||||
namespace Retailcrm\Retailcrm\Test\Unit\Model\Service;
|
namespace Retailcrm\Retailcrm\Test\Unit\Model\Service;
|
||||||
|
|
||||||
class OrderTest extends \PHPUnit\Framework\TestCase
|
use Retailcrm\Retailcrm\Test\TestCase;
|
||||||
|
|
||||||
|
class OrderTest extends TestCase
|
||||||
{
|
{
|
||||||
private $mockProductRepository;
|
private $mockProductRepository;
|
||||||
private $mockHelper;
|
private $mockHelper;
|
||||||
@ -50,11 +52,12 @@ class OrderTest extends \PHPUnit\Framework\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_status/processing'),
|
|
||||||
$this->equalTo('retailcrm/retailcrm_payment/checkmo'),
|
|
||||||
$this->equalTo('retailcrm/retailcrm_shipping/flatrate'),
|
|
||||||
$this->equalTo('retailcrm/retailcrm_site/default')
|
$this->equalTo('retailcrm/retailcrm_site/default')
|
||||||
))->will($this->returnCallback([$this, 'getCallbackDataConfig']));
|
))->will($this->returnCallback([$this, 'getCallbackDataConfig']));
|
||||||
|
|
||||||
@ -166,9 +169,6 @@ class OrderTest extends \PHPUnit\Framework\TestCase
|
|||||||
public function getCallbackDataConfig($key)
|
public function getCallbackDataConfig($key)
|
||||||
{
|
{
|
||||||
$data = [
|
$data = [
|
||||||
'retailcrm/retailcrm_status/processing' => 'new',
|
|
||||||
'retailcrm/retailcrm_payment/checkmo' => 'test',
|
|
||||||
'retailcrm/retailcrm_shipping/flatrate' => 'test',
|
|
||||||
'retailcrm/retailcrm_site/default' => 'test'
|
'retailcrm/retailcrm_site/default' => 'test'
|
||||||
];
|
];
|
||||||
|
|
||||||
|
@ -34,17 +34,29 @@
|
|||||||
<source_model>Retailcrm\Retailcrm\Model\Setting\Attribute</source_model>
|
<source_model>Retailcrm\Retailcrm\Model\Setting\Attribute</source_model>
|
||||||
</field>
|
</field>
|
||||||
</group>
|
</group>
|
||||||
<group id="shipping" translate="label" type="select" sortOrder="30" showInDefault="1" showInWebsite="1" showInStore="1">
|
<group id="shippingList" translate="label" type="select" sortOrder="30" showInDefault="1" showInWebsite="1" showInStore="1">
|
||||||
<label>Delivery types</label>
|
<label>Delivery types</label>
|
||||||
<frontend_model>Retailcrm\Retailcrm\Block\Adminhtml\System\Config\Form\Fieldset\Shipping</frontend_model>
|
<field id="shippingList" translate="label" sortOrder="5" showInDefault="1" showInWebsite="1" showInStore="1">
|
||||||
|
<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="payment" translate="label comment" type="select" sortOrder="40" showInDefault="1" showInWebsite="1" showInStore="1">
|
<group id="paymentList" translate="label" type="select" sortOrder="30" showInDefault="1" showInWebsite="1" showInStore="1">
|
||||||
<label>Payment types</label>
|
<label>Payment types</label>
|
||||||
<frontend_model>Retailcrm\Retailcrm\Block\Adminhtml\System\Config\Form\Fieldset\Payment</frontend_model>
|
<field id="paymentList" translate="label" sortOrder="5" showInDefault="1" showInWebsite="1" showInStore="1">
|
||||||
|
<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="status" translate="label" type="select" sortOrder="50" showInDefault="1" showInWebsite="1" showInStore="1">
|
<group id="statusList" translate="label" type="select" sortOrder="30" showInDefault="1" showInWebsite="1" showInStore="1">
|
||||||
<label>Order statuses</label>
|
<label>Status types</label>
|
||||||
<frontend_model>Retailcrm\Retailcrm\Block\Adminhtml\System\Config\Form\Fieldset\Status</frontend_model>
|
<field id="statusList" translate="label" sortOrder="5" showInDefault="1" showInWebsite="1" showInStore="1">
|
||||||
|
<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>
|
||||||
|
Loading…
Reference in New Issue
Block a user