Skip to content

Commit

Permalink
2.2.0 - Push events and UI updates
Browse files Browse the repository at this point in the history
  • Loading branch information
bnayalivne committed May 8, 2017
1 parent 4c5c556 commit 53f6c63
Show file tree
Hide file tree
Showing 59 changed files with 2,575 additions and 703 deletions.
24 changes: 24 additions & 0 deletions Api/Data/QueueCollectionInterface.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
<?php
namespace Remarkety\Mgconnector\Api\Data;

/**
* Defines a data structure representing a point, to demonstrating passing
* more complex types in and out of a function call.
*/
interface QueueCollectionInterface
{
/**
* Get rules.
*
* @return \Remarkety\Mgconnector\Api\Data\QueueInterface[]
*/
public function getQueueItems();

/**
* Set rules .
*
* @param \Remarkety\Mgconnector\Api\Data\QueueInterface[] $items
* @return $this
*/
public function setQueueItems(array $items = null);
}
27 changes: 24 additions & 3 deletions Api/Data/QueueInterface.php
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<?php
namespace Remarkety\Mgconnector\Api\Data;

interface QueueInterface {
interface QueueInterface extends \Magento\Framework\Api\ExtensibleDataInterface {
/**
* Get ID
*
Expand All @@ -19,7 +19,7 @@ public function getEventType();
/**
* Get URL Key
*
* @return array|null
* @return string|null
*/
public function getPayload();

Expand Down Expand Up @@ -97,4 +97,25 @@ public function setNextAttempt($nextAttempt);
* @return \Remarkety\Mgconnector\Api\Data\QueueInterface
*/
public function setStatus($status);
}

/**
* @return string|null
*/
public function getLastErrorMessage();

/**
* @return \Remarkety\Mgconnector\Api\Data\QueueInterface
*/
public function setLastErrorMessage($message);

/**
* @return int
*/
public function getStoreId();

/**
* @param int $storeId
* @return \Remarkety\Mgconnector\Api\Data\QueueInterface
*/
public function setStoreId($storeId);
}
50 changes: 50 additions & 0 deletions Api/DataInterface.php
Original file line number Diff line number Diff line change
Expand Up @@ -143,4 +143,54 @@ public function getStoreOrderStatuses();
* @return mixed $response
*/
public function createCoupon($ruleId, $couponCode, $expiration = null);

/**
* @param int|null $mage_store_id
* @param string $configName
* @param string $scope
* @return string
*/
public function getConfig($mage_store_id, $configName, $scope);

/**
* @param int|null $mage_store_id
* @param string $configName
* @param string $scope
* @param string $newValue
* @return string
*/
public function setConfig($mage_store_id, $configName, $scope, $newValue);

/**
* @return string
*/
public function getVersion();

/**
* @param int $mage_store_id
* @param int|null $limit
* @param int|null $page
* @param int|null $minId
* @param int|null $maxId
* @return \Remarkety\Mgconnector\Api\Data\QueueCollectionInterface
*/
public function getQueueItems($mage_store_id, $limit = null, $page = null, $minId = null, $maxId = null);

/**
* @param int $mage_store_id
* @param int|null $minId
* @param int|null $maxId
* @return mixed
*/
public function deleteQueueItems($mage_store_id, $minId = null, $maxId = null);

/**
* @param int $mage_store_id
* @param int|null $limit
* @param int|null $page
* @param int|null $minId
* @param int|null $maxId
* @return int
*/
public function retryQueueItems($mage_store_id, $limit = null, $page = null, $minId = null, $maxId = null);
}
18 changes: 18 additions & 0 deletions Api/QueueRepositoryInterface.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
<?php
namespace Remarkety\Mgconnector\Api;

use Remarkety\Mgconnector\Api\Data\QueueInterface;
use Magento\Framework\Api\SearchCriteriaInterface;

interface QueueRepositoryInterface
{
public function save(QueueInterface $page);

public function getById($id);

public function getList(SearchCriteriaInterface $criteria);

public function delete(QueueInterface $page);

public function deleteById($id);
}
74 changes: 74 additions & 0 deletions Block/Adminhtml/Install/Grid.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,74 @@
<?php

/**
* Adminhtml queue grid block
*
* @category Remarkety
* @package Remarkety_Mgconnector
* @author Piotr Pierzak <piotrek.pierzak@gmail.com>
*/
namespace Remarkety\Mgconnector\Block\Adminhtml\Install;

use \Magento\Store\Model\ResourceModel\Store\Collection as StoreCollection;
use \Remarkety\Mgconnector\Model\QueueFactory;
use \Magento\Catalog\Model\ProductFactory;

class Grid extends \Magento\Backend\Block\Widget\Grid\Extended
{
public function __construct(
\Magento\Backend\Block\Template\Context $context,
\Magento\Backend\Helper\Data $backendHelper,
array $data = []
)
{
parent::__construct($context, $backendHelper, $data);
$this->setPagerVisibility(false);
$this->setFilterVisibility(false);
}

public function getRowUrl($item)
{
return '';
}

protected function _prepareCollection()
{
$objectManager = \Magento\Framework\App\ObjectManager::getInstance();
/** @var \Magento\Store\Model\ResourceModel\Store\Collection $collection */
$collection = $objectManager->create('Magento\Store\Model\ResourceModel\Store\Collection');

$collection->addOrder('website_id')->addOrder('group_id');

$this->setCollection($collection);
parent::_prepareCollection();
return $this;
}

protected function _prepareColumns()
{
$this->addColumn('website_id', [
'header' => __('Website'),
'index' => 'website_id',
'renderer' => 'Remarkety\Mgconnector\Block\Adminhtml\Install\Grid\Render\Website'
]);

$this->addColumn('group_id', [
'header' => __('Store'),
'index' => 'group_id',
'renderer' => 'Remarkety\Mgconnector\Block\Adminhtml\Install\Grid\Render\Group'
]);

$this->addColumn('name', array(
'header' => __('Store view'),
'index' => 'name'
));

$this->addColumn('store_id', [
'header' => __('Status'),
'index' => 'store_id',
'renderer' => 'Remarkety\Mgconnector\Block\Adminhtml\Install\Grid\Render\Status'
]);

return parent::_prepareColumns();
}
}
30 changes: 30 additions & 0 deletions Block/Adminhtml/Install/Grid/Render/Group.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
<?php
/**
* Copyright © 2016 Magento. All rights reserved.
* See COPYING.txt for license details.
*/
namespace Remarkety\Mgconnector\Block\Adminhtml\Install\Grid\Render;

/**
* Store render website
*
* @author Magento Core Team <core@magentocommerce.com>
*/
class Group extends \Magento\Backend\Block\Widget\Grid\Column\Renderer\AbstractRenderer
{

/**
* {@inheritdoc}
*/
public function render(\Magento\Framework\DataObject $row)
{
$objectManager = \Magento\Framework\App\ObjectManager::getInstance();
/**
* @var $groupRepository \Magento\Store\Model\GroupRepository
*/
$groupRepository = $objectManager->get('Magento\Store\Model\GroupRepository');
$group = $groupRepository->get($row->getGroupId());

return $group->getName();
}
}
44 changes: 44 additions & 0 deletions Block/Adminhtml/Install/Grid/Render/Status.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
<?php
/**
* Copyright © 2016 Magento. All rights reserved.
* See COPYING.txt for license details.
*/
namespace Remarkety\Mgconnector\Block\Adminhtml\Install\Grid\Render;
use Remarkety\Mgconnector\Helper\ConfigHelper;

/**
* Store render website
*
* @author Magento Core Team <core@magentocommerce.com>
*/
class Status extends \Magento\Backend\Block\Widget\Grid\Column\Renderer\AbstractRenderer
{

/**
* {@inheritdoc}
*/
public function render(\Magento\Framework\DataObject $row)
{
$objectManager = \Magento\Framework\App\ObjectManager::getInstance();
/**
* @var $configHelper ConfigHelper
*/
$configHelper = $objectManager->get('Remarkety\Mgconnector\Helper\ConfigHelper');
$installed = $configHelper->isStoreInstalled($row->getStoreId());
if($installed){
$ret = '<span style="color:green">'. __('Connected') .'</span>';

$publicId = $configHelper->getRemarketyPublicId($row->getStoreId());
if(empty($publicId)){
$ret .= '<br />';
$ret .= '<span style="color:red">(' . __('Missing Remarkety\'s store id; website tracking and live updates will not work.') . ')</span>';
}

return $ret;
} else {
return '<button id="install_button_'.$row->getStoreId().'" type="button" class="scalable save" onclick="window.location = \''. $this->getUrl('*/install/install', ['mode' => \Remarkety\Mgconnector\Model\Install::MODE_INSTALL_LOGIN, 'store' => $row->getStoreId()]) .'\'" style="">
Connect to Remarkety
</button>';
}
}
}
30 changes: 30 additions & 0 deletions Block/Adminhtml/Install/Grid/Render/Website.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
<?php
/**
* Copyright © 2016 Magento. All rights reserved.
* See COPYING.txt for license details.
*/
namespace Remarkety\Mgconnector\Block\Adminhtml\Install\Grid\Render;

/**
* Store render website
*
* @author Magento Core Team <core@magentocommerce.com>
*/
class Website extends \Magento\Backend\Block\Widget\Grid\Column\Renderer\AbstractRenderer
{

/**
* {@inheritdoc}
*/
public function render(\Magento\Framework\DataObject $row)
{
$objectManager = \Magento\Framework\App\ObjectManager::getInstance();
/**
* @var $websiteRepo \Magento\Store\Model\WebsiteRepository
*/
$websiteRepo = $objectManager->get('Magento\Store\Model\WebsiteRepository');
$website = $websiteRepo->getById($row->getWebsiteId());

return $website->getName();
}
}
14 changes: 12 additions & 2 deletions Block/Adminhtml/Install/Install.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,14 +2,24 @@
namespace Remarkety\Mgconnector\Block\Adminhtml\Install;


use Remarkety\Mgconnector\Helper\ConfigHelper;

class Install extends \Magento\Framework\View\Element\Template
{
public $configHelper;

public function __construct(\Magento\Framework\View\Element\Template\Context $context,
\Remarkety\Mgconnector\Helper\Data $remarketyHelper){
\Remarkety\Mgconnector\Helper\Data $remarketyHelper,
ConfigHelper $configHelper){
parent::__construct($context);
$this->remarketyHelper = $remarketyHelper;
$this->configHelper = $configHelper;
}

public function getStoresGrid(){
$block = $this->getLayout()->createBlock('Remarkety\Mgconnector\Block\Adminhtml\Install\Grid');
return $block->toHtml();
}

protected function _toHtml()
{
Expand All @@ -21,4 +31,4 @@ protected function _toHtml()
public function getHelperMode(){
return $this->remarketyHelper->getMode();
}
}
}
8 changes: 6 additions & 2 deletions Block/Adminhtml/Install/Install/Login/Form.php
Original file line number Diff line number Diff line change
Expand Up @@ -66,10 +66,14 @@ protected function _prepareForm()
'class' => 'required-entry admin__control-text'
));

$options = $this->_systemStore->getStoreValuesForForm(false, false);
$selected_store_id = $this->getRequest()->getParam('store');

$fieldset->addField('store_id', 'select', array(
'name' => 'data[store_id]',
'label' =>__('Sync Remarkety with this view:'),
'values' => $this->_systemStore->getStoreValuesForForm(false, false)
'values' => $options,
'value' => $selected_store_id
));

$fieldset->addField('button', 'note', array(
Expand All @@ -88,4 +92,4 @@ public function currentStore($id = null) {
$manager = $om->get('Magento\Store\Model\StoreManagerInterface');
return $manager->getStore($id);
}
}
}
Loading

0 comments on commit 53f6c63

Please sign in to comment.