1
0
mirror of synced 2024-11-25 06:26:07 +03:00

Merge pull request #19 from iyzoer/master

Изменена логика передачи данных по заказам и клиентам
This commit is contained in:
Alex Lushpai 2019-01-23 13:46:36 +03:00 committed by GitHub
commit b15f8ec5a8
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
16 changed files with 456 additions and 45 deletions

View File

@ -0,0 +1,89 @@
<?php
namespace Retailcrm\Retailcrm\Block\Frontend;
class DaemonCollector extends \Magento\Framework\View\Element\Template
{
private $customer;
private $helper;
private $storeManager;
private $storeResolver;
private $js = '';
private $template = <<<EOT
<script type="text/javascript">
(function(_,r,e,t,a,i,l){_['retailCRMObject']=a;_[a]=_[a]||function(){(_[a].q=_[a].q||[]).push(arguments)};_[a].l=1*new Date();l=r.getElementsByTagName(e)[0];i=r.createElement(e);i.async=!0;i.src=t;l.parentNode.insertBefore(i,l)})(window,document,'script','https://collector.retailcrm.pro/w.js','_rc');
{{ code }}
_rc('send', 'pageView');
</script>
EOT;
/**
* DaemonCollector constructor.
*
* @param \Magento\Framework\View\Element\Template\Context $context
* @param \Magento\Customer\Model\Session $customerSession
* @param \Magento\Store\Model\StoreManagerInterface $storeManager
* @param \Magento\Store\Api\StoreResolverInterface $storeResolver
* @param \Retailcrm\Retailcrm\Helper\Data $helper
* @param array $data
*/
public function __construct(
\Magento\Framework\View\Element\Template\Context $context,
\Magento\Customer\Model\Session $customerSession,
\Magento\Store\Model\StoreManagerInterface $storeManager,
\Magento\Store\Api\StoreResolverInterface $storeResolver,
\Retailcrm\Retailcrm\Helper\Data $helper,
array $data = []
) {
parent::__construct($context, $data);
$this->customer = $customerSession->getCustomer();
$this->storeManager = $storeManager;
$this->storeResolver = $storeResolver;
$this->helper = $helper;
}
/**
* @return string
*/
public function getJs()
{
return $this->js;
}
/**
* @return $this
*/
public function buildScript()
{
$params = array();
if ($this->customer->getId()) {
$params['customerId'] = $this->customer->getId();
}
try {
$siteKey = $this->helper->getSiteKey(
$this->storeManager->getStore(
$this->storeResolver->getCurrentStoreId()
)->getWebsiteId()
);
} catch (\Magento\Framework\Exception\NoSuchEntityException $entityException) {
return $this;
}
if ($siteKey) {
$this->js = preg_replace(
'/{{ code }}/',
sprintf(
"\t_rc('create', '%s', %s);\n",
$siteKey,
json_encode((object) $params)
),
$this->template
);
}
return $this;
}
}

View File

@ -2,6 +2,7 @@
namespace Retailcrm\Retailcrm\Helper; namespace Retailcrm\Retailcrm\Helper;
use Magento\Framework\App\Config\ScopeConfigInterface;
use Magento\Framework\App\Helper\AbstractHelper; use Magento\Framework\App\Helper\AbstractHelper;
use Magento\Store\Model\StoreManagerInterface; use Magento\Store\Model\StoreManagerInterface;
use Magento\Framework\App\Helper\Context; use Magento\Framework\App\Helper\Context;
@ -14,6 +15,7 @@ class Data extends AbstractHelper
const XML_PATH_RETAILCRM = 'retailcrm/'; const XML_PATH_RETAILCRM = 'retailcrm/';
const XML_PATH_DEFAULT_SITE = 'retailcrm_site/default'; const XML_PATH_DEFAULT_SITE = 'retailcrm_site/default';
const XML_PATH_SITES = 'retailcrm_sites/'; const XML_PATH_SITES = 'retailcrm_sites/';
const XML_PATH_DAEMON_COLLECTOR = 'daemon_collector/';
public function __construct( public function __construct(
Context $context, Context $context,
@ -45,6 +47,7 @@ class Data extends AbstractHelper
* @param $store * @param $store
* *
* @return mixed|null * @return mixed|null
* @throws \Exception
*/ */
public function getSite($store) public function getSite($store)
{ {
@ -70,6 +73,9 @@ class Data extends AbstractHelper
return $websitesConfig; return $websitesConfig;
} }
/**
* @return array
*/
public function getMappingSites() public function getMappingSites()
{ {
$sites = []; $sites = [];
@ -90,6 +96,72 @@ class Data extends AbstractHelper
return $sites; return $sites;
} }
/**
* @param $website
*
* @return array|bool
*/
public function getDaemonCollector($website)
{
$forWebsite = $this->scopeConfig->getValue(
self::XML_PATH_RETAILCRM . self::XML_PATH_DAEMON_COLLECTOR . 'active',
ScopeInterface::SCOPE_WEBSITES,
$website
);
if ($forWebsite) {
return [
'website' => $website,
'active' => $forWebsite
];
}
$forDefault = $this->scopeConfig->getValue(
self::XML_PATH_RETAILCRM . self::XML_PATH_DAEMON_COLLECTOR . 'active',
ScopeConfigInterface::SCOPE_TYPE_DEFAULT
);
if ($forDefault) {
return [
'website' => 0,
'active' => $forDefault
];
}
return false;
}
/**
* @param $website
*
* @return bool|mixed
*/
public function getSiteKey($website)
{
$daemonCollector = $this->getDaemonCollector($website);
if ($daemonCollector === false) {
return false;
}
if ($daemonCollector['active']) {
if ($daemonCollector['website'] > 0) {
return $this->scopeConfig->getValue(
self::XML_PATH_RETAILCRM . self::XML_PATH_DAEMON_COLLECTOR . 'key',
ScopeInterface::SCOPE_WEBSITES,
$website
);
} else {
return $this->scopeConfig->getValue(
self::XML_PATH_RETAILCRM . self::XML_PATH_DAEMON_COLLECTOR . 'key',
ScopeConfigInterface::SCOPE_TYPE_DEFAULT
);
}
}
return false;
}
/** /**
* Recursive array filter * Recursive array filter
* *

View File

@ -15,6 +15,7 @@ class OrderCreate implements \Magento\Framework\Event\ObserverInterface
private $registry; private $registry;
private $order; private $order;
private $serviceOrder; private $serviceOrder;
private $serviceCustomer;
/** /**
* Constructor * Constructor
@ -22,6 +23,7 @@ class OrderCreate implements \Magento\Framework\Event\ObserverInterface
* @param \Magento\Framework\Registry $registry * @param \Magento\Framework\Registry $registry
* @param \Retailcrm\Retailcrm\Model\Logger\Logger $logger * @param \Retailcrm\Retailcrm\Model\Logger\Logger $logger
* @param \Retailcrm\Retailcrm\Model\Service\Order $serviceOrder * @param \Retailcrm\Retailcrm\Model\Service\Order $serviceOrder
* @param \Retailcrm\Retailcrm\Model\Service\Customer $serviceCustomer
* @param Helper $helper * @param Helper $helper
* @param ApiClient $api * @param ApiClient $api
*/ */
@ -29,12 +31,14 @@ class OrderCreate implements \Magento\Framework\Event\ObserverInterface
\Magento\Framework\Registry $registry, \Magento\Framework\Registry $registry,
\Retailcrm\Retailcrm\Model\Logger\Logger $logger, \Retailcrm\Retailcrm\Model\Logger\Logger $logger,
\Retailcrm\Retailcrm\Model\Service\Order $serviceOrder, \Retailcrm\Retailcrm\Model\Service\Order $serviceOrder,
\Retailcrm\Retailcrm\Model\Service\Customer $serviceCustomer,
Helper $helper, Helper $helper,
ApiClient $api ApiClient $api
) { ) {
$this->logger = $logger; $this->logger = $logger;
$this->registry = $registry; $this->registry = $registry;
$this->serviceOrder = $serviceOrder; $this->serviceOrder = $serviceOrder;
$this->serviceCustomer = $serviceCustomer;
$this->helper = $helper; $this->helper = $helper;
$this->api = $api; $this->api = $api;
$this->order = []; $this->order = [];
@ -55,6 +59,7 @@ class OrderCreate implements \Magento\Framework\Event\ObserverInterface
return false; return false;
} }
/** @var \Magento\Sales\Model\Order $order */
$order = $observer->getEvent()->getOrder(); $order = $observer->getEvent()->getOrder();
$this->api->setSite($this->helper->getSite($order->getStore())); $this->api->setSite($this->helper->getSite($order->getStore()));
@ -62,13 +67,8 @@ class OrderCreate implements \Magento\Framework\Event\ObserverInterface
return false; return false;
} }
$billingAddress = $order->getBillingAddress();
$this->order = $this->serviceOrder->process($order); $this->order = $this->serviceOrder->process($order);
$this->setCustomer($order);
$this->setCustomer(
$order,
$billingAddress
);
Helper::filterRecursive($this->order); Helper::filterRecursive($this->order);
@ -80,16 +80,22 @@ class OrderCreate implements \Magento\Framework\Event\ObserverInterface
} }
/** /**
* @param $order * @param \Magento\Sales\Model\Order $order
* @param $billingAddress * @param \Magento\Sales\Model\Order\Address $billingAddress
*/ */
private function setCustomer($order, $billingAddress) private function setCustomer($order)
{ {
if ($order->getCustomerIsGuest() == 1) { if ($order->getCustomerIsGuest() == 1) {
$customer = $this->getCustomerByEmail($order->getCustomerEmail()); $customer = $this->getCustomerByEmail($order->getCustomerEmail());
if ($customer !== false) { if ($customer !== false) {
$this->order['customer']['id'] = $customer['id']; $this->order['customer']['id'] = $customer['id'];
} else {
$newCustomer = $this->serviceCustomer->prepareCustomerFromOrder($order);
$response = $this->api->customersCreate($newCustomer);
if ($response && isset($response['id'])) {
$this->order['customer']['id'] = $response['id'];
}
} }
} }
@ -97,18 +103,7 @@ class OrderCreate implements \Magento\Framework\Event\ObserverInterface
if ($this->existsInCrm($order->getCustomerId(), 'customersGet')) { if ($this->existsInCrm($order->getCustomerId(), 'customersGet')) {
$this->order['customer']['externalId'] = $order->getCustomerId(); $this->order['customer']['externalId'] = $order->getCustomerId();
} else { } else {
$preparedCustomer = [ $preparedCustomer = $this->serviceCustomer->process($order->getCustomer());
'externalId' => $order->getCustomerId(),
'firstName' => $order->getCustomerFirstname(),
'lastName' => $order->getCustomerLastname(),
'email' => $order->getCustomerEmail()
];
if ($billingAddress->getTelephone()) {
$preparedCustomer['phones'][] = [
'number' => $billingAddress->getTelephone()
];
}
if ($this->api->customersCreate($preparedCustomer)) { if ($this->api->customersCreate($preparedCustomer)) {
$this->order['customer']['externalId'] = $order->getCustomerId(); $this->order['customer']['externalId'] = $order->getCustomerId();

View File

@ -25,7 +25,6 @@ class Customer implements CustomerManagerInterface
* @param \Magento\Customer\Model\Customer $customer * @param \Magento\Customer\Model\Customer $customer
* *
* @return array $preparedCustomer * @return array $preparedCustomer
* @throws \Magento\Framework\Exception\LocalizedException
*/ */
public function process(\Magento\Customer\Model\Customer $customer) public function process(\Magento\Customer\Model\Customer $customer)
{ {
@ -60,6 +59,49 @@ class Customer implements CustomerManagerInterface
return $preparedCustomer; return $preparedCustomer;
} }
/**
* @param \Magento\Sales\Model\Order $order
*
* @return array
*/
public function prepareCustomerFromOrder(\Magento\Sales\Model\Order $order)
{
$billing = $order->getBillingAddress();
$preparedCustomer = [
'externalId' => uniqid(),
'email' => $billing->getEmail(),
'firstName' => $billing->getFirstname(),
'patronymic' => $billing->getMiddlename(),
'lastName' => $billing->getLastname(),
'createdAt' => $order->getCreatedAt(),
'address' => [
'countryIso' => $billing->getCountryId(),
'index' => $billing->getPostcode(),
'region' => $billing->getRegion(),
'city' => $billing->getCity(),
'street' => $billing->getStreet(),
'text' => sprintf(
'%s %s %s %s',
$billing->getPostcode(),
$billing->getRegion(),
$billing->getCity(),
$billing->getStreet()
)
]
];
if ($billing->getTelephone()) {
$preparedCustomer['phones'] = [
[
'number' => $billing->getTelephone()
]
];
}
return $preparedCustomer;
}
private function getAddress(\Magento\Customer\Model\Customer $customer) private function getAddress(\Magento\Customer\Model\Customer $customer)
{ {
$billingAddress = $customer->getDefaultBillingAddress(); $billingAddress = $customer->getDefaultBillingAddress();

View File

@ -34,7 +34,6 @@ class Order implements \Retailcrm\Retailcrm\Api\OrderManagerInterface
{ {
$items = $order->getAllItems(); $items = $order->getAllItems();
$products = $this->addProducts($items); $products = $this->addProducts($items);
$billingAddress = $order->getBillingAddress();
$shippingAddress = $order->getShippingAddress(); $shippingAddress = $order->getShippingAddress();
$shipping = $this->getShippingCode($order->getShippingMethod()); $shipping = $this->getShippingCode($order->getShippingMethod());
@ -42,11 +41,11 @@ class Order implements \Retailcrm\Retailcrm\Api\OrderManagerInterface
'externalId' => $order->getId(), 'externalId' => $order->getId(),
'number' => $order->getRealOrderId(), 'number' => $order->getRealOrderId(),
'createdAt' => $order->getCreatedAt(), 'createdAt' => $order->getCreatedAt(),
'lastName' => $order->getCustomerLastname(), 'lastName' => $shippingAddress->getLastname(),
'firstName' => $order->getCustomerFirstname(), 'firstName' => $shippingAddress->getFirstname(),
'patronymic' => $order->getCustomerMiddlename(), 'patronymic' => $shippingAddress->getMiddlename(),
'email' => $order->getCustomerEmail(), 'email' => $shippingAddress->getEmail(),
'phone' => $billingAddress->getTelephone(), 'phone' => $shippingAddress->getTelephone(),
'status' => $this->config->getValue('retailcrm/retailcrm_status/' . $order->getStatus()), 'status' => $this->config->getValue('retailcrm/retailcrm_status/' . $order->getStatus()),
'items' => $products, 'items' => $products,
'delivery' => [ 'delivery' => [
@ -73,8 +72,8 @@ class Order implements \Retailcrm\Retailcrm\Api\OrderManagerInterface
] ]
]; ];
if ($billingAddress->getData('country_id')) { if ($shippingAddress->getData('country_id')) {
$preparedOrder['countryIso'] = $billingAddress->getData('country_id'); $preparedOrder['countryIso'] = $shippingAddress->getData('country_id');
} }
if ($this->helper->getGeneralSettings('api_version') == 'v4') { if ($this->helper->getGeneralSettings('api_version') == 'v4') {

View File

@ -0,0 +1,14 @@
<?php
namespace Retailcrm\Retailcrm\Model\Setting;
class DaemonCollector implements \Magento\Framework\Option\ArrayInterface
{
public function toOptionArray()
{
return [
['value' => true, 'label' => __('Yes')],
['value' => false, 'label' => __('No')]
];
}
}

View File

@ -0,0 +1,75 @@
<?php
class DaemonCollectorTest extends \PHPUnit\Framework\TestCase
{
private $unit;
private $customer;
const SITE_KEY = 'RC-XXXXXXX-X';
public function setUp()
{
$objectManager = new \Magento\Framework\TestFramework\Unit\Helper\ObjectManager($this);
$context = $objectManager->getObject(\Magento\Framework\View\Element\Template\Context::class);
$customerSession = $this->createMock(\Magento\Customer\Model\Session::class);
$storeManager = $this->createMock(\Magento\Store\Model\StoreManager::class);
$storeResolver = $this->createMock(\Magento\Store\Model\StoreResolver::class);
$helper = $this->createMock(\Retailcrm\Retailcrm\Helper\Data::class);
$this->customer = $this->createMock(\Magento\Customer\Model\Customer::class);
$store = $this->createMock(\Magento\Store\Model\Store::class);
$customerSession->expects($this->any())
->method('getCustomer')
->willReturn($this->customer);
$storeResolver->expects($this->any())
->method('getCurrentStoreId')
->willReturn(1);
$store->expects($this->any())
->method('getWebsiteId')
->willReturn(1);
$storeManager->expects($this->any())
->method('getStore')
->willReturn($store);
$helper->expects($this->any())
->method('getSiteKey')
->willReturn(self::SITE_KEY);
$this->unit = new \Retailcrm\Retailcrm\Block\Frontend\DaemonCollector(
$context,
$customerSession,
$storeManager,
$storeResolver,
$helper
);
}
public function testGetJSWithCustomer()
{
$this->customer->expects($this->any())
->method('getId')
->willReturn(1);
$js = $this->unit->buildScript()->getJs();
$this->assertContains('<script type="text/javascript">', $js);
$this->assertContains('</script>', $js);
$this->assertContains('_rc(\'send\', \'pageView\');', $js);
$this->assertContains(self::SITE_KEY, $js);
$this->assertContains('customerId', $js);
}
public function testGetJSWithoutCustomer()
{
$this->customer->expects($this->any())
->method('getId')
->willReturn(null);
$js = $this->unit->buildScript()->getJs();
$this->assertContains('<script type="text/javascript">', $js);
$this->assertContains('</script>', $js);
$this->assertContains('_rc(\'send\', \'pageView\');', $js);
$this->assertContains(self::SITE_KEY, $js);
$this->assertNotContains('customerId', $js);
}
}

View File

@ -20,6 +20,8 @@ class OrderCreateTest extends \PHPUnit\Framework\TestCase
private $mockLogger; private $mockLogger;
private $mockServiceOrder; private $mockServiceOrder;
private $mockHelper; private $mockHelper;
private $mockServiceCustomer;
private $mockCustomer;
public function setUp() public function setUp()
{ {
@ -56,6 +58,12 @@ class OrderCreateTest extends \PHPUnit\Framework\TestCase
$this->mockOrder = $this->getMockBuilder(\Magento\Sales\Model\Order::class) $this->mockOrder = $this->getMockBuilder(\Magento\Sales\Model\Order::class)
->disableOriginalConstructor() ->disableOriginalConstructor()
->setMethods([
'getCustomer',
'getId',
'getBillingAddress',
'getStore'
])
->getMock(); ->getMock();
$this->mockStore = $this->getMockBuilder(\Magento\Store\Model\Store::class) $this->mockStore = $this->getMockBuilder(\Magento\Store\Model\Store::class)
@ -81,10 +89,62 @@ class OrderCreateTest extends \PHPUnit\Framework\TestCase
->disableOriginalConstructor() ->disableOriginalConstructor()
->getMock(); ->getMock();
$this->mockServiceCustomer = $this->getMockBuilder(\Retailcrm\Retailcrm\Model\Service\Customer::class)
->disableOriginalConstructor()
->getMock();
$this->mockServiceCustomer->expects($this->any())->method('process')->willReturn($this->getCustomerTestData());
$this->mockServiceCustomer
->expects($this->any())
->method('prepareCustomerFromOrder')
->willReturn(
$this->getCustomerTestData()
);
$this->mockCustomer = $this->getMockBuilder(\Magento\Customer\Model\Customer::class)
->disableOriginalConstructor()
->setMethods([
'getId',
'getEmail',
'getFirstname',
'getMiddlename',
'getLastname',
'getStore',
'getGender',
'getDob',
'getDefaultBillingAddress',
'getAddressesCollection'
])
->getMock();
$testData = $this->getAfterSaveCustomerTestData();
// mock Customer
$this->mockCustomer->expects($this->any())
->method('getId')
->willReturn($testData['id']);
$this->mockCustomer->expects($this->any())
->method('getEmail')
->willReturn($testData['email']);
$this->mockCustomer->expects($this->any())
->method('getFirstname')
->willReturn($testData['firstname']);
$this->mockCustomer->expects($this->any())
->method('getMiddlename')
->willReturn($testData['middlename']);
$this->mockCustomer->expects($this->any())
->method('getLastname')
->willReturn($testData['lastname']);
$this->unit = new \Retailcrm\Retailcrm\Model\Observer\OrderCreate( $this->unit = new \Retailcrm\Retailcrm\Model\Observer\OrderCreate(
$this->mockRegistry, $this->mockRegistry,
$this->mockLogger, $this->mockLogger,
$this->mockServiceOrder, $this->mockServiceOrder,
$this->mockServiceCustomer,
$this->mockHelper, $this->mockHelper,
$this->mockApi $this->mockApi
); );
@ -177,6 +237,10 @@ class OrderCreateTest extends \PHPUnit\Framework\TestCase
->method('getStore') ->method('getStore')
->willReturn($this->mockStore); ->willReturn($this->mockStore);
$this->mockOrder->expects($this->any())
->method('getCustomer')
->willReturn($this->mockCustomer);
// mock Event // mock Event
$this->mockEvent->expects($this->any()) $this->mockEvent->expects($this->any())
->method('getOrder') ->method('getOrder')
@ -379,4 +443,37 @@ class OrderCreateTest extends \PHPUnit\Framework\TestCase
] ]
]; ];
} }
/**
* Get test customer data
*
* @return array
*/
private function getAfterSaveCustomerTestData()
{
return [
'id' => 1,
'email' => 'test@mail.com',
'firstname' => 'TestFirstname',
'lastname' => 'Testlastname',
'middlename' => 'Testmiddlename',
'birthday' => '1990-01-01',
'gender' => 1
];
}
/**
* @return array
*/
private function getCustomerTestData()
{
return [
'externalId' => 1,
'email' => 'test@mail.com',
'firstName' => 'TestFirstname',
'lastName' => 'Testlastname',
'patronymic' => 'Testmiddlename',
'createdAt' => \date('Y-m-d H:i:s')
];
}
} }

View File

@ -90,7 +90,14 @@ class OrderTest extends \PHPUnit\Framework\TestCase
$mockShippingAddress = $this->getMockBuilder(\Magento\Sales\Model\Order\Address::class) $mockShippingAddress = $this->getMockBuilder(\Magento\Sales\Model\Order\Address::class)
->disableOriginalConstructor() ->disableOriginalConstructor()
->setMethods(['getData']) ->setMethods([
'getData',
'getTelephone',
'getFirstname',
'getLastname',
'getMiddlename',
'getEmail'
])
->getMock(); ->getMock();
$mockShippingAddress->expects($this->any()) $mockShippingAddress->expects($this->any())
->method('getData') ->method('getData')
@ -103,11 +110,11 @@ class OrderTest extends \PHPUnit\Framework\TestCase
)) ))
->will($this->returnCallback([$this, 'getCallbackDataAddress'])); ->will($this->returnCallback([$this, 'getCallbackDataAddress']));
$mockBillingAddress = $this->getMockBuilder(\Magento\Sales\Model\Order\Address::class) $mockShippingAddress->expects($this->any())->method('getTelephone')->willReturn('89000000000');
->disableOriginalConstructor() $mockShippingAddress->expects($this->any())->method('getFirstname')->willReturn('Test');
->setMethods(['getTelephone']) $mockShippingAddress->expects($this->any())->method('getLastname')->willReturn('Test');
->getMock(); $mockShippingAddress->expects($this->any())->method('getMiddlename')->willReturn('Test');
$mockBillingAddress->expects($this->any())->method('getTelephone')->willReturn('89000000000'); $mockShippingAddress->expects($this->any())->method('getEmail')->willReturn('test@mail.com');
$mockPaymentMethod = $this->getMockBuilder(\Magento\Payment\Model\MethodInterface::class) $mockPaymentMethod = $this->getMockBuilder(\Magento\Payment\Model\MethodInterface::class)
->disableOriginalConstructor() ->disableOriginalConstructor()
@ -121,16 +128,11 @@ class OrderTest extends \PHPUnit\Framework\TestCase
$mockPayment->expects($this->any())->method('getMethodInstance')->willReturn($mockPaymentMethod); $mockPayment->expects($this->any())->method('getMethodInstance')->willReturn($mockPaymentMethod);
$this->mockOrder->expects($this->any())->method('getAllItems')->willReturn([$mockItem]); $this->mockOrder->expects($this->any())->method('getAllItems')->willReturn([$mockItem]);
$this->mockOrder->expects($this->any())->method('getBillingAddress')->willReturn($mockBillingAddress);
$this->mockOrder->expects($this->any())->method('getShippingAddress')->willReturn($mockShippingAddress); $this->mockOrder->expects($this->any())->method('getShippingAddress')->willReturn($mockShippingAddress);
$this->mockOrder->expects($this->any())->method('getShippingMethod')->willReturn('flatrate_flatrate'); $this->mockOrder->expects($this->any())->method('getShippingMethod')->willReturn('flatrate_flatrate');
$this->mockOrder->expects($this->any())->method('getId')->willReturn(1); $this->mockOrder->expects($this->any())->method('getId')->willReturn(1);
$this->mockOrder->expects($this->any())->method('getRealOrderId')->willReturn('000000001'); $this->mockOrder->expects($this->any())->method('getRealOrderId')->willReturn('000000001');
$this->mockOrder->expects($this->any())->method('getCreatedAt')->willReturn(date('Y-m-d H:i:s')); $this->mockOrder->expects($this->any())->method('getCreatedAt')->willReturn(date('Y-m-d H:i:s'));
$this->mockOrder->expects($this->any())->method('getCustomerLastname')->willReturn('Test');
$this->mockOrder->expects($this->any())->method('getCustomerFirstname')->willReturn(date('Test'));
$this->mockOrder->expects($this->any())->method('getCustomerMiddlename')->willReturn(date('Test'));
$this->mockOrder->expects($this->any())->method('getCustomerEmail')->willReturn('test@mail.com');
$this->mockOrder->expects($this->any())->method('getStatus')->willReturn('processing'); $this->mockOrder->expects($this->any())->method('getStatus')->willReturn('processing');
$this->mockOrder->expects($this->any())->method('getShippingAmount')->willReturn(100); $this->mockOrder->expects($this->any())->method('getShippingAmount')->willReturn(100);
$this->mockOrder->expects($this->any())->method('getDiscountAmount')->willReturn(0); $this->mockOrder->expects($this->any())->method('getDiscountAmount')->willReturn(0);

View File

@ -64,6 +64,16 @@
<label>Setting the stores correspondence</label> <label>Setting the stores correspondence</label>
<frontend_model>Retailcrm\Retailcrm\Block\Adminhtml\System\Config\Form\Fieldset\Sites</frontend_model> <frontend_model>Retailcrm\Retailcrm\Block\Adminhtml\System\Config\Form\Fieldset\Sites</frontend_model>
</group> </group>
<group id="daemon_collector" translate="label" type="select" sortOrder="70" showInDefault="1" showInWebsite="1" showInStore="0">
<label>Daemon Collector</label>
<field id="active" translate="label" type="select" sortOrder="30" showInDefault="1" showInWebsite="1" showInStore="0">
<label>Activate</label>
<source_model>Retailcrm\Retailcrm\Model\Setting\DaemonCollector</source_model>
</field>
<field id="key" translate="label" type="text" sortOrder="30" showInDefault="1" showInWebsite="1" showInStore="0">
<label>Site key</label>
</field>
</group>
</section> </section>
</system> </system>
</config> </config>

View File

@ -4,10 +4,8 @@
<job name="create_icml" instance="Retailcrm\Retailcrm\Cron\Icml" method="execute"> <job name="create_icml" instance="Retailcrm\Retailcrm\Cron\Icml" method="execute">
<schedule>* */4 * * *</schedule> <schedule>* */4 * * *</schedule>
</job> </job>
<job name="order_hystory" instance="Retailcrm\Retailcrm\Cron\OrderHistory" method="execute"> <job name="order_hystory" instance="Retailcrm\Retailcrm\Cron\OrderHistory" method="execute">
<schedule>*/5 * * * *</schedule> <schedule>*/5 * * * *</schedule>
</job> </job>
</group> </group>
</config> </config>

View File

@ -22,3 +22,5 @@
"The selected API version is unavailable","La versión de la API seleccionada no está disponible" "The selected API version is unavailable","La versión de la API seleccionada no está disponible"
"Send","Enviar" "Send","Enviar"
"Default site","Tienda por defecto" "Default site","Tienda por defecto"
"Activate","Active"
"Site key","Clave de la página web"
1 Settings La configuración
22 The selected API version is unavailable La versión de la API seleccionada no está disponible
23 Send Enviar
24 Default site Tienda por defecto
25 Activate Active
26 Site key Clave de la página web

View File

@ -22,3 +22,5 @@
"The selected API version is unavailable","Выбранная версия API недоступна" "The selected API version is unavailable","Выбранная версия API недоступна"
"Send","Выгрузить" "Send","Выгрузить"
"Default site","Сайт по умолчанию" "Default site","Сайт по умолчанию"
"Activate","Активировать"
"Site key","Ключ сайта"
1 Settings Настройки
22 The selected API version is unavailable Выбранная версия API недоступна
23 Send Выгрузить
24 Default site Сайт по умолчанию
25 Activate Активировать
26 Site key Ключ сайта

View File

@ -0,0 +1,8 @@
<?xml version="1.0"?>
<page xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" layout="1column" xsi:noNamespaceSchemaLocation="urn:magento:framework:View/Layout/etc/page_configuration.xsd">
<body>
<referenceBlock name="head.additional">
<block class="Retailcrm\Retailcrm\Block\Frontend\DaemonCollector" name="block_name" template="Retailcrm_Retailcrm::daemon_collector.phtml" />
</referenceBlock>
</body>
</page>

View File

@ -3,4 +3,9 @@
<referenceContainer name="content"> <referenceContainer name="content">
<block class="Retailcrm\Retailcrm\Block\Display" name="retailcrm_display" template="Retailcrm_Retailcrm::sayhello.phtml" /> <block class="Retailcrm\Retailcrm\Block\Display" name="retailcrm_display" template="Retailcrm_Retailcrm::sayhello.phtml" />
</referenceContainer> </referenceContainer>
<body>
<referenceBlock name="head.additional">
<block class="Retailcrm\Retailcrm\Block\Frontend\DaemonCollector" name="block_name" template="Retailcrm_Retailcrm::daemon_collector.phtml" />
</referenceBlock>
</body>
</page> </page>

View File

@ -0,0 +1 @@
<?php echo $block->buildScript()->getJs() ?>