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
|
||||
|
||||
sudo: false
|
||||
if: tag IS blank
|
||||
|
||||
env:
|
||||
global:
|
||||
@ -13,34 +15,210 @@ env:
|
||||
- ADMIN_USER=admin
|
||||
- ADMIN_PASS=admin123
|
||||
|
||||
matrix:
|
||||
stages:
|
||||
- test
|
||||
|
||||
jobs:
|
||||
include:
|
||||
- php: 7.0
|
||||
env: BRANCH=2.0.2
|
||||
|
||||
- php: 7.0
|
||||
env: BRANCH=2.2.5
|
||||
- php: 7.1
|
||||
env: BRANCH=2.2.5
|
||||
- php: 7.0
|
||||
env: BRANCH=2.0.4
|
||||
|
||||
- php: 7.0
|
||||
env: BRANCH=2.2.6
|
||||
- php: 7.1
|
||||
env: BRANCH=2.2.6
|
||||
- php: 7.0
|
||||
env: BRANCH=2.0.5
|
||||
|
||||
- php: 7.0
|
||||
env: BRANCH=2.2.7
|
||||
- php: 7.1
|
||||
env: BRANCH=2.2.7
|
||||
- php: 7.0
|
||||
env: BRANCH=2.0.6
|
||||
|
||||
- php: 7.0
|
||||
env: BRANCH=2.2.8
|
||||
- php: 7.1
|
||||
env: BRANCH=2.2.8
|
||||
- php: 7.0
|
||||
env: BRANCH=2.0.7
|
||||
|
||||
- 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:
|
||||
- bash bin/install.sh
|
||||
|
||||
script:
|
||||
- bash bin/script.sh
|
||||
script: make ci
|
||||
|
||||
# deploy:
|
||||
# skip_cleanup: true
|
||||
|
4
Makefile
4
Makefile
@ -1,6 +1,7 @@
|
||||
FILE = $(TRAVIS_BUILD_DIR)/VERSION
|
||||
VERSION = `cat $(FILE)`
|
||||
ARCHIVE_NAME = '/tmp/retailcrm-retailcrm-'$(VERSION)'.zip'
|
||||
MAGE_ROOT = $(TRAVIS_BUILD_DIR)/../magento2
|
||||
|
||||
all: build_archive send_to_ftp delete_archive
|
||||
|
||||
@ -12,3 +13,6 @@ send_to_ftp:
|
||||
|
||||
delete_archive:
|
||||
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
|
||||
cd magento2
|
||||
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
|
||||
}
|
||||
|
||||
|
@ -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;
|
||||
}
|
||||
|
||||
if ($response->isSuccessful()) {
|
||||
if (isset($response['paymentTypes']) && $response->isSuccessful()) {
|
||||
$paymentsTypes = $response['paymentTypes'];
|
||||
} else {
|
||||
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 = [];
|
||||
|
||||
$response = $this->client->deliveryTypesList();
|
||||
try {
|
||||
$response = $this->client->deliveryTypesList();
|
||||
} catch (\Exception $exception) {
|
||||
return $defaultValues;
|
||||
}
|
||||
|
||||
if ($response === false) {
|
||||
return $defaultValues;
|
||||
}
|
||||
|
||||
if ($response->isSuccessful()) {
|
||||
if (isset($response['deliveryTypes']) && $response->isSuccessful()) {
|
||||
$deliveryTypes = $response['deliveryTypes'];
|
||||
} else {
|
||||
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 = [];
|
||||
|
||||
$response = $this->client->sitesList();
|
||||
try {
|
||||
$response = $this->client->sitesList();
|
||||
} catch (\Exception $exception) {
|
||||
return $defaultValues;
|
||||
}
|
||||
|
||||
if ($response === false) {
|
||||
return $defaultValues;
|
||||
}
|
||||
|
||||
if ($response->isSuccessful()) {
|
||||
if (isset($response['sites']) && $response->isSuccessful()) {
|
||||
$sites = $response['sites'];
|
||||
} else {
|
||||
return $defaultValues;
|
||||
|
@ -115,13 +115,17 @@ class Sites extends \Magento\Config\Block\System\Config\Form\Fieldset
|
||||
|
||||
$values = [];
|
||||
|
||||
$response = $this->client->sitesList();
|
||||
try {
|
||||
$response = $this->client->sitesList();
|
||||
} catch (\Exception $exception) {
|
||||
return $defaultValues;
|
||||
}
|
||||
|
||||
if ($response === false) {
|
||||
return $defaultValues;
|
||||
}
|
||||
|
||||
if ($response->isSuccessful()) {
|
||||
if (isset($response['sites']) && $response->isSuccessful()) {
|
||||
$sites = $response['sites'];
|
||||
} else {
|
||||
return $defaultValues;
|
||||
|
@ -111,13 +111,17 @@ class Status extends \Magento\Config\Block\System\Config\Form\Fieldset
|
||||
|
||||
$values = [];
|
||||
|
||||
$response = $this->client->statusesList();
|
||||
try {
|
||||
$response = $this->client->statusesList();
|
||||
} catch (\Exception $exception) {
|
||||
return $defaultValues;
|
||||
}
|
||||
|
||||
if ($response === false) {
|
||||
return $defaultValues;
|
||||
}
|
||||
|
||||
if ($response->isSuccessful()) {
|
||||
if (isset($response['statuses']) && $response->isSuccessful()) {
|
||||
$statuses = $response['statuses'];
|
||||
} else {
|
||||
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 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');
|
||||
|
||||
$payments = $this->config->getValue('retailcrm/retailcrm_payment');
|
||||
$shippings = $this->config->getValue('retailcrm/retailcrm_shipping');
|
||||
$payments = $this->helper->getConfigPayments();
|
||||
$shippings = $this->helper->getCongigShipping();
|
||||
$sites = $this->helper->getMappingSites();
|
||||
|
||||
if ($sites && in_array($order['site'], $sites)) {
|
||||
@ -242,7 +242,7 @@ class Exchange
|
||||
//add items in quote
|
||||
foreach ($ditems as $id =>$item) {
|
||||
$product = $productRepository->getById($id,false, $store->getId(), false);
|
||||
$product->setPrice($item['price_item']);
|
||||
$product->setPrice($item['initialPrice']);
|
||||
$quote->addProduct(
|
||||
$product,
|
||||
(int)$item['quantity']
|
||||
@ -349,8 +349,8 @@ class Exchange
|
||||
$order = $response['order'];
|
||||
}
|
||||
|
||||
$payments = $this->config->getValue('retailcrm/retailcrm_payment');
|
||||
$shippings = $this->config->getValue('retailcrm/retailcrm_shipping');
|
||||
$payments = $this->helper->getConfigPayments();
|
||||
$shippings = $this->helper->getCongigShipping();
|
||||
|
||||
$region = $this->regionFactory->create();
|
||||
$sites = $this->helper->getMappingSites();
|
||||
@ -411,7 +411,7 @@ class Exchange
|
||||
//add items in quote
|
||||
foreach ($ditems as $id => $item) {
|
||||
$product = $productRepository->getById($id,false, $store->getId(), false);
|
||||
$product->setPrice($item['price_item']);
|
||||
$product->setPrice($item['initialPrice']);
|
||||
$quote->addProduct(
|
||||
$product,
|
||||
(int)$item['quantity']
|
||||
@ -520,7 +520,7 @@ class Exchange
|
||||
{
|
||||
$this->logger->writeDump($order, 'doUpdate');
|
||||
|
||||
$Status = $this->config->getValue('retailcrm/retailcrm_status');
|
||||
$Status = $this->helper->getCongigStatus();
|
||||
$Status = array_flip(array_filter($Status));
|
||||
|
||||
$magentoOrder = $this->order->load($order['externalId']);
|
||||
|
@ -53,9 +53,11 @@ class OrderUpdate implements \Magento\Framework\Event\ObserverInterface
|
||||
$order = $observer->getEvent()->getOrder();
|
||||
|
||||
if ($order) {
|
||||
$statusList = $this->helper->getCongigStatus();
|
||||
|
||||
$this->order = [
|
||||
'externalId' => $order->getId(),
|
||||
'status' => $this->config->getValue('retailcrm/retailcrm_status/' . $order->getStatus())
|
||||
'status' => $statusList[$order->getStatus()]
|
||||
];
|
||||
|
||||
if ($order->getBaseTotalDue() == 0) {
|
||||
|
@ -3,6 +3,7 @@
|
||||
namespace Retailcrm\Retailcrm\Model\Service;
|
||||
|
||||
use Retailcrm\Retailcrm\Helper\Data as Helper;
|
||||
use Magento\Framework\App\Config\ScopeConfigInterface;
|
||||
|
||||
class IntegrationModule
|
||||
{
|
||||
@ -110,9 +111,15 @@ class IntegrationModule
|
||||
}
|
||||
|
||||
if ($response->isSuccessful() && $active == true) {
|
||||
|
||||
$scope = ScopeConfigInterface::SCOPE_TYPE_DEFAULT;
|
||||
$scopeId = 0;
|
||||
|
||||
$this->resourceConfig->saveConfig(
|
||||
Helper::XML_PATH_RETAILCRM . 'general/client_id_in_crm',
|
||||
$this->clientId
|
||||
$this->clientId,
|
||||
$scope,
|
||||
$scopeId
|
||||
);
|
||||
|
||||
return true;
|
||||
|
@ -37,6 +37,10 @@ class Order implements \Retailcrm\Retailcrm\Api\OrderManagerInterface
|
||||
$shippingAddress = $order->getShippingAddress();
|
||||
$shipping = $this->getShippingCode($order->getShippingMethod());
|
||||
|
||||
$shipList = $this->helper->getCongigShipping();
|
||||
$statusList = $this->helper->getCongigStatus();
|
||||
$paymentList = $this->helper->getConfigPayments();
|
||||
|
||||
$preparedOrder = [
|
||||
'externalId' => $order->getId(),
|
||||
'number' => $order->getRealOrderId(),
|
||||
@ -46,10 +50,10 @@ class Order implements \Retailcrm\Retailcrm\Api\OrderManagerInterface
|
||||
'patronymic' => $shippingAddress->getMiddlename(),
|
||||
'email' => $shippingAddress->getEmail(),
|
||||
'phone' => $shippingAddress->getTelephone(),
|
||||
'status' => $this->config->getValue('retailcrm/retailcrm_status/' . $order->getStatus()),
|
||||
'status' => $statusList[$order->getStatus()],
|
||||
'items' => $products,
|
||||
'delivery' => [
|
||||
'code' => $this->config->getValue('retailcrm/retailcrm_shipping/' . $shipping),
|
||||
'code' => $shipList[$shipping],
|
||||
'cost' => $order->getShippingAmount(),
|
||||
'address' => [
|
||||
'index' => $shippingAddress->getData('postcode'),
|
||||
@ -80,15 +84,11 @@ class Order implements \Retailcrm\Retailcrm\Api\OrderManagerInterface
|
||||
|
||||
if ($this->helper->getGeneralSettings('api_version') == 'v4') {
|
||||
$preparedOrder['discount'] = abs($order->getDiscountAmount());
|
||||
$preparedOrder['paymentType'] = $this->config->getValue(
|
||||
'retailcrm/retailcrm_payment/' . $order->getPayment()->getMethodInstance()->getCode()
|
||||
);
|
||||
$preparedOrder['paymentType'] = $paymentList[$order->getPayment()->getMethodInstance()->getCode()];
|
||||
} elseif ($this->helper->getGeneralSettings('api_version') == 'v5') {
|
||||
$preparedOrder['discountManualAmount'] = abs($order->getDiscountAmount());
|
||||
$payment = [
|
||||
'type' => $this->config->getValue(
|
||||
'retailcrm/retailcrm_payment/' . $order->getPayment()->getMethodInstance()->getCode()
|
||||
),
|
||||
'type'=> $paymentList[$order->getPayment()->getMethodInstance()->getCode()],
|
||||
'externalId' => $codeShop.$order->getId(),
|
||||
'order' => [
|
||||
'externalId' => $order->getId(),
|
||||
|
@ -2,7 +2,9 @@
|
||||
|
||||
namespace Retailcrm\Retailcrm\Test\Helpers;
|
||||
|
||||
class FieldsetTest extends \PHPUnit\Framework\TestCase
|
||||
use Retailcrm\Retailcrm\Test\TestCase;
|
||||
|
||||
class FieldsetTest extends TestCase
|
||||
{
|
||||
protected $elementMock;
|
||||
protected $authSessionMock;
|
||||
@ -100,7 +102,7 @@ class FieldsetTest extends \PHPUnit\Framework\TestCase
|
||||
\Magento\Config\Block\System\Config\Form::class,
|
||||
['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);
|
||||
}
|
||||
}
|
||||
|
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;
|
||||
|
||||
class DaemonCollectorTest extends \PHPUnit\Framework\TestCase
|
||||
use Retailcrm\Retailcrm\Test\TestCase;
|
||||
|
||||
class DaemonCollectorTest extends TestCase
|
||||
{
|
||||
private $unit;
|
||||
private $customer;
|
||||
|
@ -2,7 +2,9 @@
|
||||
|
||||
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 $mockResponse;
|
||||
|
@ -2,10 +2,12 @@
|
||||
|
||||
namespace Retailcrm\Retailcrm\Test\Unit\Observer;
|
||||
|
||||
use Retailcrm\Retailcrm\Test\TestCase;
|
||||
|
||||
/**
|
||||
* Order create observer test class
|
||||
*/
|
||||
class OrderCreateTest extends \PHPUnit\Framework\TestCase
|
||||
class OrderCreateTest extends TestCase
|
||||
{
|
||||
private $unit;
|
||||
private $mockEvent;
|
||||
|
@ -2,7 +2,9 @@
|
||||
|
||||
namespace Retailcrm\Retailcrm\Test\Unit\Observer;
|
||||
|
||||
class OrderUpdateTest extends \PHPUnit\Framework\TestCase
|
||||
use Retailcrm\Retailcrm\Test\TestCase;
|
||||
|
||||
class OrderUpdateTest extends TestCase
|
||||
{
|
||||
private $unit;
|
||||
private $objectManager;
|
||||
|
@ -2,7 +2,9 @@
|
||||
|
||||
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 $mockCustomer;
|
||||
|
@ -2,7 +2,9 @@
|
||||
|
||||
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 $mockApiClient;
|
||||
|
@ -2,7 +2,9 @@
|
||||
|
||||
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 $mockProductRepository;
|
||||
@ -18,12 +20,12 @@ class InventoriesUploadTest extends \PHPUnit\Framework\TestCase
|
||||
'isConfigured'
|
||||
])
|
||||
->getMock();
|
||||
|
||||
|
||||
$this->mockProductRepository = $this->getMockBuilder(\Magento\Catalog\Api\ProductRepositoryInterface::class)
|
||||
->disableOriginalConstructor()
|
||||
->setMethods(['getById'])
|
||||
->getMockForAbstractClass();
|
||||
|
||||
|
||||
$this->mockResponse = $this->getMockBuilder(\RetailCrm\Response\ApiResponse::class)
|
||||
->disableOriginalConstructor()
|
||||
->setMethods(['isSuccessful'])
|
||||
@ -47,6 +49,7 @@ class InventoriesUploadTest extends \PHPUnit\Framework\TestCase
|
||||
{
|
||||
if ($response != false) {
|
||||
$responseInventories = new \RetailCrm\Response\ApiResponse(200, json_encode($response));
|
||||
$responseInventories->asJsonResponse($response);
|
||||
|
||||
$this->mockResponse->expects($this->any())
|
||||
->method('isSuccessful')
|
||||
@ -88,9 +91,9 @@ class InventoriesUploadTest extends \PHPUnit\Framework\TestCase
|
||||
}
|
||||
|
||||
public function dataProviderLoadStocks()
|
||||
{
|
||||
{
|
||||
$response = $this->getResponseData();
|
||||
|
||||
|
||||
return array(
|
||||
array(
|
||||
'response' => $response['true']
|
||||
@ -100,7 +103,7 @@ class InventoriesUploadTest extends \PHPUnit\Framework\TestCase
|
||||
)
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
private function getApiInventories()
|
||||
{
|
||||
return array(
|
||||
|
@ -2,7 +2,9 @@
|
||||
|
||||
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 $mockHelper;
|
||||
@ -50,11 +52,12 @@ class OrderTest extends \PHPUnit\Framework\TestCase
|
||||
$this->mockHelper->expects($this->any())->method('getGeneralSettings')
|
||||
->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')
|
||||
->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')
|
||||
))->will($this->returnCallback([$this, 'getCallbackDataConfig']));
|
||||
|
||||
@ -166,9 +169,6 @@ class OrderTest extends \PHPUnit\Framework\TestCase
|
||||
public function getCallbackDataConfig($key)
|
||||
{
|
||||
$data = [
|
||||
'retailcrm/retailcrm_status/processing' => 'new',
|
||||
'retailcrm/retailcrm_payment/checkmo' => 'test',
|
||||
'retailcrm/retailcrm_shipping/flatrate' => 'test',
|
||||
'retailcrm/retailcrm_site/default' => 'test'
|
||||
];
|
||||
|
||||
|
@ -34,17 +34,29 @@
|
||||
<source_model>Retailcrm\Retailcrm\Model\Setting\Attribute</source_model>
|
||||
</field>
|
||||
</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>
|
||||
<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 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>
|
||||
<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 id="status" translate="label" type="select" sortOrder="50" showInDefault="1" showInWebsite="1" showInStore="1">
|
||||
<label>Order statuses</label>
|
||||
<frontend_model>Retailcrm\Retailcrm\Block\Adminhtml\System\Config\Form\Fieldset\Status</frontend_model>
|
||||
<group id="statusList" translate="label" type="select" sortOrder="30" showInDefault="1" showInWebsite="1" showInStore="1">
|
||||
<label>Status types</label>
|
||||
<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 id="load" translate="label" type="text" sortOrder="80" showInDefault="1" showInWebsite="1" showInStore="1">
|
||||
<label>Uploading orders</label>
|
||||
|
Loading…
Reference in New Issue
Block a user