diff --git a/Block/Adminhtml/Dashboard.php b/Block/Adminhtml/Dashboard.php
index f7139f7..f834a4e 100644
--- a/Block/Adminhtml/Dashboard.php
+++ b/Block/Adminhtml/Dashboard.php
@@ -4,6 +4,7 @@
use Clerk\Clerk\Model\Config;
use Magento\Backend\Block\Template;
+use Magento\Backend\Block\Template\Context;
use Magento\Store\Api\StoreRepositoryInterface;
use Magento\Store\Model\ScopeInterface;
@@ -17,6 +18,11 @@ class Dashboard extends Template
*/
private $storeRepository;
+ /**
+ * @param Context $context
+ * @param StoreRepositoryInterface $storeRepository
+ * @param array $data
+ */
public function __construct(Template\Context $context, StoreRepositoryInterface $storeRepository, array $data = [])
{
$this->storeRepository = $storeRepository;
@@ -52,7 +58,7 @@ public function getEmbedUrl()
$storePart = $this->getStorePart($publicKey);
- return sprintf('https://my.clerk.io/#/store/%s/analytics/%s?key=%s&private_key=%s&embed=yes', $storePart, $this->type, $publicKey, $privateKey);
+ return sprintf("https://my.clerk.io/#/store/%s/analytics/%s?key=%s&private_key=%s&embed=yes", $storePart, $this->type, $publicKey, $privateKey);
}
/**
@@ -76,7 +82,7 @@ public function getStore()
/**
* Get first 8 characters of public key
*
- * @param $publicKey
+ * @param string $publicKey
* @return string
*/
protected function getStorePart($publicKey)
diff --git a/Block/Adminhtml/Insights/Audience.php b/Block/Adminhtml/Insights/Audience.php
index f215e94..3591a1b 100644
--- a/Block/Adminhtml/Insights/Audience.php
+++ b/Block/Adminhtml/Insights/Audience.php
@@ -6,5 +6,9 @@
class Audience extends Dashboard
{
+
+ /**
+ * @var string
+ */
protected $type = 'audience';
}
diff --git a/Block/Adminhtml/Insights/Email.php b/Block/Adminhtml/Insights/Email.php
index 750d68d..81d2584 100644
--- a/Block/Adminhtml/Insights/Email.php
+++ b/Block/Adminhtml/Insights/Email.php
@@ -6,5 +6,8 @@
class Email extends Dashboard
{
+ /**
+ * @var string
+ */
protected $type = 'email';
}
diff --git a/Block/Adminhtml/Insights/Recommendations.php b/Block/Adminhtml/Insights/Recommendations.php
index 6d6404e..a43dc7c 100644
--- a/Block/Adminhtml/Insights/Recommendations.php
+++ b/Block/Adminhtml/Insights/Recommendations.php
@@ -6,5 +6,8 @@
class Recommendations extends Dashboard
{
+ /**
+ * @var string
+ */
protected $type = 'recommendations';
}
diff --git a/Block/Adminhtml/Insights/Search.php b/Block/Adminhtml/Insights/Search.php
index 96ed965..83a6f62 100644
--- a/Block/Adminhtml/Insights/Search.php
+++ b/Block/Adminhtml/Insights/Search.php
@@ -6,5 +6,8 @@
class Search extends Dashboard
{
+ /**
+ * @var string
+ */
protected $type = 'search';
}
diff --git a/Block/Adminhtml/System/Config/Field/FacetTitles.php b/Block/Adminhtml/System/Config/Field/FacetTitles.php
index ccdcbb9..e726fcf 100644
--- a/Block/Adminhtml/System/Config/Field/FacetTitles.php
+++ b/Block/Adminhtml/System/Config/Field/FacetTitles.php
@@ -2,75 +2,46 @@
namespace Clerk\Clerk\Block\Adminhtml\System\Config\Field;
+use Clerk\Clerk\Helper\Config as ConfigHelper;
use Clerk\Clerk\Model\Config;
+use Magento\Backend\Block\Template\Context;
use Magento\Config\Block\System\Config\Form\Field;
-use Magento\Store\Model\ScopeInterface;
+use Magento\Framework\Data\Form\Element\AbstractElement;
+use Magento\Framework\Exception\NoSuchEntityException;
class FacetTitles extends Field
{
- /**
- * @var RequestInterface
- */
- protected $requestInterface;
/**
* FacetTitles constructor.
- * @param \Magento\Backend\Block\Template\Context $context
+ * @param ConfigHelper $configHelper
+ * @param Context $context
* @param array $data
*/
public function __construct(
- \Magento\Backend\Block\Template\Context $context,
- \Magento\Framework\App\RequestInterface $requestInterface,
+ ConfigHelper $configHelper,
+ Context $context,
array $data = []
) {
- $this->requestInterface = $requestInterface;
+ $this->configHelper = $configHelper;
$this->setTemplate('Clerk_Clerk::facettitles.phtml');
parent::__construct($context, $data);
}
- /**
- * Get html for element
- *
- * @param \Magento\Framework\Data\Form\Element\AbstractElement $element
- * @return string
- */
- protected function _getElementHtml(\Magento\Framework\Data\Form\Element\AbstractElement $element)
- {
- $this->setElement($element);
-
- $html = '';
-
- $html .= $this->toHtml();
-
- return $html;
- }
-
/**
* Get configured facet attributes
*/
public function getConfiguredAttributes()
{
- $_params = $this->requestInterface->getParams();
- $scope_id = '0';
- $scope = 'default';
- if (array_key_exists('website', $_params)) {
- $scope = 'website';
- $scope_id = $_params[$scope];
- }
- if (array_key_exists('store', $_params)) {
- $scope = 'store';
- $scope_id = $_params[$scope];
- }
- $attributes = $this->_scopeConfig->getValue(Config::XML_PATH_FACETED_SEARCH_ATTRIBUTES, $scope, $scope_id);
- $configuredAttributes = is_string($attributes) ? explode(',', $attributes) : [];
-
- return $configuredAttributes;
+ $attributes = $this->configHelper->getValueAdmin(Config::XML_PATH_FACETED_SEARCH_ATTRIBUTES);
+ return is_string($attributes) ? explode(',', $attributes) : [];
}
/**
* Get label for current scope
*
* @return string
+ * @throws NoSuchEntityException
*/
public function getScopeLabel()
{
@@ -90,4 +61,17 @@ public function getStoreId()
return $this->getData('store_id');
}
+
+ /**
+ * Get html for element
+ *
+ * @param AbstractElement $element
+ * @return string
+ */
+ protected function _getElementHtml(AbstractElement $element)
+ {
+ $this->setElement($element);
+
+ return $this->toHtml();
+ }
}
diff --git a/Block/Adminhtml/System/Config/Field/MultiselectFacetAttributes.php b/Block/Adminhtml/System/Config/Field/MultiselectFacetAttributes.php
index 095ddd2..afe082c 100644
--- a/Block/Adminhtml/System/Config/Field/MultiselectFacetAttributes.php
+++ b/Block/Adminhtml/System/Config/Field/MultiselectFacetAttributes.php
@@ -2,55 +2,42 @@
namespace Clerk\Clerk\Block\Adminhtml\System\Config\Field;
+use Clerk\Clerk\Helper\Config as ConfigHelper;
use Clerk\Clerk\Model\Config;
+use Magento\Backend\Block\Template\Context;
use Magento\Config\Block\System\Config\Form\Field;
-use Magento\Store\Model\ScopeInterface;
+use Magento\Framework\Data\Form\Element\AbstractElement;
class MultiselectFacetAttributes extends Field
{
- /**
- * @var RequestInterface
- */
- protected $requestInterface;
-
/**
* FacetTitles constructor.
- * @param \Magento\Backend\Block\Template\Context $context
+ * @param ConfigHelper $configHelper
+ * @param Context $context
* @param array $data
*/
public function __construct(
- \Magento\Backend\Block\Template\Context $context,
- \Magento\Framework\App\RequestInterface $requestInterface,
- array $data = []
- ) {
- $this->requestInterface = $requestInterface;
+ ConfigHelper $configHelper,
+ Context $context,
+ array $data = []
+ )
+ {
parent::__construct($context, $data);
+ $this->configHelper = $configHelper;
}
/**
* Get element html if facet attributes are configured
*
- * @param \Magento\Framework\Data\Form\Element\AbstractElement $element
+ * @param AbstractElement $element
* @return string
*/
- public function render(\Magento\Framework\Data\Form\Element\AbstractElement $element)
+ public function render(AbstractElement $element)
{
- $_params = $this->requestInterface->getParams();
- $scope_id = '0';
- $scope = 'default';
- if (array_key_exists('website', $_params)) {
- $scope = 'website';
- $scope_id = $_params[$scope];
- }
- if (array_key_exists('store', $_params)) {
- $scope = 'store';
- $scope_id = $_params[$scope];
- }
- if ($this->_scopeConfig->getValue(Config::XML_PATH_FACETED_SEARCH_ATTRIBUTES, $scope, $scope_id)) {
+ if ($this->configHelper->getValueAdmin(Config::XML_PATH_FACETED_SEARCH_ATTRIBUTES)) {
return parent::render($element);
}
-
return '';
}
}
diff --git a/Block/Adminhtml/System/Config/Fieldset/FacetedSearch.php b/Block/Adminhtml/System/Config/Fieldset/FacetedSearch.php
index 9651404..1299bc3 100644
--- a/Block/Adminhtml/System/Config/Fieldset/FacetedSearch.php
+++ b/Block/Adminhtml/System/Config/Fieldset/FacetedSearch.php
@@ -2,12 +2,17 @@
namespace Clerk\Clerk\Block\Adminhtml\System\Config\Fieldset;
+use Clerk\Clerk\Helper\Config as ConfigHelper;
use Clerk\Clerk\Model\Api;
use Clerk\Clerk\Model\Config;
-use Magento\Config\Model\ResourceModel\Config as SystemConfig;
+use Exception;
+use Magento\Backend\Block\Context;
+use Magento\Backend\Model\Auth\Session;
use Magento\Config\Block\System\Config\Form\Fieldset;
+use Magento\Config\Model\ResourceModel\Config as SystemConfig;
+use Magento\Framework\App\RequestInterface;
use Magento\Framework\Data\Form\Element\AbstractElement;
-use Magento\Store\Model\ScopeInterface;
+use Magento\Framework\View\Helper\Js;
class FacetedSearch extends Fieldset
{
@@ -29,26 +34,30 @@ class FacetedSearch extends Fieldset
/**
* FacetedSearch constructor.
*
- * @param \Magento\Backend\Block\Context $context
- * @param \Magento\Backend\Model\Auth\Session $authSession
- * @param \Magento\Framework\View\Helper\Js $jsHelper
- * @param \Magento\Framework\App\RequestInterface $requestInterface
+ * @param ConfigHelper $configHelper
+ * @param Context $context
+ * @param Session $authSession
+ * @param Js $jsHelper
+ * @param RequestInterface $requestInterface
* @param Api $api
+ * @param SystemConfig $systemConfig
* @param array $data
*/
public function __construct(
- \Magento\Backend\Block\Context $context,
- \Magento\Backend\Model\Auth\Session $authSession,
- \Magento\Framework\View\Helper\Js $jsHelper,
- \Magento\Framework\App\RequestInterface $requestInterface,
- Api $api,
- SystemConfig $systemConfig,
- array $data = []
- ) {
+ ConfigHelper $configHelper,
+ Context $context,
+ Session $authSession,
+ Js $jsHelper,
+ RequestInterface $requestInterface,
+ Api $api,
+ SystemConfig $systemConfig,
+ array $data = []
+ )
+ {
$this->api = $api;
$this->systemConfig = $systemConfig;
$this->requestInterface = $requestInterface;
-
+ $this->configHelper = $configHelper;
parent::__construct($context, $authSession, $jsHelper, $data);
}
@@ -57,16 +66,17 @@ public function __construct(
*
* @param AbstractElement $element
* @return string
+ * @throws Exception
*/
public function render(AbstractElement $element)
{
$this->setElement($element);
$header = $this->_getHeaderHtml($element);
- if (! $this->isConfigured()) {
+ if (!$this->isConfigured()) {
$elements = __('Public and private key must be set in order to enable faceted search');
} else {
- if (! $this->keysValid()) {
+ if (!$this->keysValid()) {
$elements = __('Public or private key invalid');
} else {
$elements = $this->_getChildrenElementsHtml($element);
@@ -86,40 +96,19 @@ public function render(AbstractElement $element)
*/
private function isConfigured()
{
- $_params = $this->requestInterface->getParams();
- $scope_id = '0';
- $scope = 'default';
- if (array_key_exists('website', $_params)) {
- $scope = 'website';
- $scope_id = $_params[$scope];
- }
- if (array_key_exists('store', $_params)) {
- $scope = 'store';
- $scope_id = $_params[$scope];
- }
- return (bool) ($this->_scopeConfig->getValue(Config::XML_PATH_PUBLIC_KEY, $scope, $scope_id) && $this->_scopeConfig->getValue(Config::XML_PATH_PRIVATE_KEY, $scope, $scope_id));
+ return $this->configHelper->getValueAdmin(Config::XML_PATH_PUBLIC_KEY) && $this->configHelper->getValueAdmin(Config::XML_PATH_PRIVATE_KEY);
}
/**
* Determine if public & private keys are valid
*
* @return bool
+ * @throws Exception
*/
private function keysValid()
{
- $_params = $this->requestInterface->getParams();
- $scope_id = '0';
- $scope = 'default';
- if (array_key_exists('website', $_params)) {
- $scope = 'website';
- $scope_id = $_params[$scope];
- }
- if (array_key_exists('store', $_params)) {
- $scope = 'store';
- $scope_id = $_params[$scope];
- }
- $publicKey = $this->_scopeConfig->getValue(Config::XML_PATH_PUBLIC_KEY, $scope, $scope_id);
- $privateKey = $this->_scopeConfig->getValue(Config::XML_PATH_PRIVATE_KEY, $scope, $scope_id);
+ $publicKey = $this->configHelper->getValueAdmin(Config::XML_PATH_PUBLIC_KEY);
+ $privateKey = $this->configHelper->getValueAdmin(Config::XML_PATH_PRIVATE_KEY);
$keysValid = json_decode($this->api->keysValid($publicKey, $privateKey));
diff --git a/Block/Adminhtml/Widget/Store.php b/Block/Adminhtml/Widget/Store.php
index 0d22dc0..aa47808 100644
--- a/Block/Adminhtml/Widget/Store.php
+++ b/Block/Adminhtml/Widget/Store.php
@@ -2,12 +2,15 @@
namespace Clerk\Clerk\Block\Adminhtml\Widget;
+use Magento\Backend\Block\Template;
use Magento\Backend\Block\Template\Context;
+use Magento\Backend\Block\Widget;
use Magento\Framework\Data\Form\Element\AbstractElement;
-use Magento\Framework\Option\ArrayPool;
use Magento\Framework\Data\Form\Element\Select as FormSelect;
+use Magento\Framework\Exception\LocalizedException;
+use Magento\Framework\Option\ArrayPool;
-class Store extends \Magento\Backend\Block\Widget
+class Store extends Widget
{
/**
@@ -16,7 +19,7 @@ class Store extends \Magento\Backend\Block\Widget
protected $_formSelect;
/**
- * @var \Magento\Framework\Option\ArrayPool
+ * @var ArrayPool
*/
protected $_sourceModelPool;
@@ -28,11 +31,11 @@ class Store extends \Magento\Backend\Block\Widget
* @param array $data
*/
public function __construct(
- Context $context,
- ArrayPool $sourceModelPool,
+ Context $context,
+ ArrayPool $sourceModelPool,
FormSelect $formSelect,
- array $data = []
- )
+ array $data = []
+ )
{
parent::__construct($context, $data);
$this->_sourceModelPool = $sourceModelPool;
@@ -44,7 +47,7 @@ public function __construct(
*
* @param AbstractElement $element Form Element
* @return AbstractElement
- * @throws \Magento\Framework\Exception\LocalizedException
+ * @throws LocalizedException
*/
public function prepareElementHtml(AbstractElement $element)
{
@@ -55,12 +58,13 @@ public function prepareElementHtml(AbstractElement $element)
);
//Since we're using block as widget parameter type we need to create the select ourselves
- /** @var \Magento\Framework\Data\Form\Element\Select $select */
$select = $this->_formSelect;
$select->setHtmlId($element->getHtmlId());
+ /** @noinspection PhpPossiblePolymorphicInvocationInspection */
$select->setName($element->getName());
$configuredValue = $element->getData();
if ($configuredValue !== null) {
+ /** @noinspection PhpPossiblePolymorphicInvocationInspection */
$select->setValue($element->getData());
}
$select->setValues($this->_sourceModelPool->get('Magento\Config\Model\Config\Source\Store')->toOptionArray());
@@ -69,7 +73,7 @@ public function prepareElementHtml(AbstractElement $element)
echo get_class($element->getForm());
//Create javascript block and append
- /** @var \Magento\Backend\Block\Template $jsBlock */
+ /** @var Template $jsBlock */
$jsBlock = $this->getLayout()->createBlock('Magento\Backend\Block\Template')
->setTemplate('Clerk_Clerk::widget.phtml')
->setAjaxUrl($ajaxUrl)
diff --git a/Block/ExitIntent.php b/Block/ExitIntent.php
index e159c53..197f700 100644
--- a/Block/ExitIntent.php
+++ b/Block/ExitIntent.php
@@ -5,15 +5,20 @@
use Clerk\Clerk\Helper\Config as ConfigHelper;
use Clerk\Clerk\Model\Config;
use Magento\Framework\View\Element\Template;
+use Magento\Framework\View\Element\Template\Context;
class ExitIntent extends Template
{
+ /**
+ * @param ConfigHelper $configHelper
+ * @param Context $context
+ * @param array $data
+ */
public function __construct(
ConfigHelper $configHelper,
Template\Context $context,
array $data = []
- )
- {
+ ) {
parent::__construct($context, $data);
$this->configHelper = $configHelper;
}
diff --git a/Block/LiveSearch.php b/Block/LiveSearch.php
index f660827..906e9a2 100644
--- a/Block/LiveSearch.php
+++ b/Block/LiveSearch.php
@@ -5,15 +5,20 @@
use Clerk\Clerk\Helper\Config as ConfigHelper;
use Clerk\Clerk\Model\Config;
use Magento\Framework\View\Element\Template;
+use Magento\Framework\View\Element\Template\Context;
class LiveSearch extends Template
{
+ /**
+ * @param ConfigHelper $configHelper
+ * @param Context $context
+ * @param array $data
+ */
public function __construct(
ConfigHelper $configHelper,
Template\Context $context,
array $data = []
- )
- {
+ ) {
parent::__construct($context, $data);
$this->configHelper = $configHelper;
}
@@ -29,6 +34,9 @@ public function getLiveSearchTemplate()
}
/**
+ * Get shop base domain url
+ *
+ * @return string
*/
public function getShopBaseDomainUrl()
{
@@ -46,6 +54,8 @@ public function shouldIncludeCategories()
}
/**
+ * Get number of suggestions
+ *
* @return mixed
*/
public function getSuggestions()
@@ -54,6 +64,8 @@ public function getSuggestions()
}
/**
+ * Get number of categories
+ *
* @return mixed
*/
public function getCategories()
@@ -62,6 +74,8 @@ public function getCategories()
}
/**
+ * Get number of pages
+ *
* @return mixed
*/
public function getPages()
@@ -70,6 +84,8 @@ public function getPages()
}
/**
+ * Get search pages type
+ *
* @return mixed
*/
public function getPagesType()
@@ -78,6 +94,8 @@ public function getPagesType()
}
/**
+ * Get injection position
+ *
* @return mixed
*/
public function getDropdownPosition()
@@ -86,6 +104,8 @@ public function getDropdownPosition()
}
/**
+ * Get live-search css selector
+ *
* @return mixed
*/
public function getInputSelector()
@@ -94,6 +114,8 @@ public function getInputSelector()
}
/**
+ * Get form element css selector
+ *
* @return mixed
*/
public function getFormSelector()
diff --git a/Block/Powerstep.php b/Block/Powerstep.php
index 77a0f27..dbb1b38 100644
--- a/Block/Powerstep.php
+++ b/Block/Powerstep.php
@@ -13,12 +13,16 @@
class Powerstep extends AbstractProduct
{
+ /**
+ * @param ConfigHelper $configHelper
+ * @param Context $context
+ * @param array $data
+ */
public function __construct(
ConfigHelper $configHelper,
Context $context,
array $data = []
- )
- {
+ ) {
parent::__construct($context, $data);
$this->configHelper = $configHelper;
}
@@ -71,6 +75,8 @@ public function getProduct()
}
/**
+ * Get content exclude flag
+ *
* @return mixed
*/
public function getExcludeState()
@@ -79,11 +85,12 @@ public function getExcludeState()
}
/**
- * @return array|string[]
+ * Get content templates
+ *
+ * @return string[]
*/
public function getTemplates()
{
return $this->configHelper->getTemplates(Config::XML_PATH_POWERSTEP_TEMPLATES);
}
-
}
diff --git a/Block/PowerstepPopup.php b/Block/PowerstepPopup.php
index 79940dd..f08bc0a 100644
--- a/Block/PowerstepPopup.php
+++ b/Block/PowerstepPopup.php
@@ -36,7 +36,6 @@ class PowerstepPopup extends Template
*/
protected $imageHelper;
-
/**
* PowerstepPopup constructor.
*
@@ -97,12 +96,14 @@ public function getProduct()
}
try {
return $this->productRepository->getById($product_id);
- } catch (NoSuchEntityException) {
+ } catch (NoSuchEntityException $ex) {
return false;
}
}
/**
+ * Get last product id added to the cart
+ *
* @return false|int
*/
public function getLastProductId()
@@ -118,8 +119,9 @@ public function getLastProductId()
if (empty($last_item)) {
return false;
}
+ /** @noinspection PhpPossiblePolymorphicInvocationInspection */
return $last_item->getProductId();
- } catch (NoSuchEntityException|LocalizedException) {
+ } catch (NoSuchEntityException|LocalizedException $ex) {
return false;
}
}
@@ -157,7 +159,7 @@ public function getImageUrl()
*/
public function shouldShow()
{
- $show_powerstep = ($this->getRequest()->getParam('isAjax')) || ($this->checkoutSession->getClerkShowPowerstep(true));
+ $show_powerstep = $this->getRequest()->getParam('isAjax') || $this->checkoutSession->getClerkShowPowerstep(true);
if ($show_powerstep) {
$this->checkoutSession->setClerkShowPowerstep(false);
@@ -176,6 +178,11 @@ public function isAjax()
return $this->getRequest()->getParam('isAjax');
}
+ /**
+ * Get content exclude state
+ *
+ * @return mixed
+ */
public function getExcludeState()
{
return $this->configHelper->getValue(Config::XML_PATH_POWERSTEP_FILTER_DUPLICATES);
diff --git a/Block/PowerstepScripts.php b/Block/PowerstepScripts.php
index a876a5a..672412e 100644
--- a/Block/PowerstepScripts.php
+++ b/Block/PowerstepScripts.php
@@ -4,16 +4,22 @@
use Clerk\Clerk\Helper\Config as ConfigHelper;
use Clerk\Clerk\Model\Config;
+use Clerk\Clerk\Model\Config\Source\PowerstepType;
use Magento\Framework\View\Element\Template;
+use Magento\Framework\View\Element\Template\Context;
class PowerstepScripts extends Template
{
+ /**
+ * @param ConfigHelper $configHelper
+ * @param Context $context
+ * @param array $data
+ */
public function __construct(
ConfigHelper $configHelper,
Template\Context $context,
array $data = []
- )
- {
+ ) {
parent::__construct($context, $data);
$this->configHelper = $configHelper;
}
@@ -25,6 +31,6 @@ public function __construct(
*/
public function shouldShow()
{
- return $this->configHelper->getValue(Config::XML_PATH_POWERSTEP_TYPE) == Config\Source\PowerstepType::TYPE_POPUP;
+ return $this->configHelper->getValue(Config::XML_PATH_POWERSTEP_TYPE) == PowerstepType::TYPE_POPUP;
}
}
diff --git a/Block/Result.php b/Block/Result.php
index 416d5ab..c1d6d6b 100644
--- a/Block/Result.php
+++ b/Block/Result.php
@@ -13,8 +13,16 @@
class Result extends BaseResult
{
- const TARGET_ID = 'clerk-search-results';
+ public const TARGET_ID = 'clerk-search-results';
+ /**
+ * @param ConfigHelper $configHelper
+ * @param Context $context
+ * @param LayerResolver $layerResolver
+ * @param Data $catalogSearchData
+ * @param QueryFactory $queryFactory
+ * @param array $data
+ */
public function __construct(
ConfigHelper $configHelper,
Context $context,
@@ -22,13 +30,14 @@ public function __construct(
Data $catalogSearchData,
QueryFactory $queryFactory,
array $data = []
- )
- {
+ ) {
parent::__construct($context, $layerResolver, $catalogSearchData, $queryFactory, $data);
$this->configHelper = $configHelper;
}
/**
+ * Get suggestions limit
+ *
* @return mixed
*/
public function getSuggestions()
@@ -61,7 +70,6 @@ public function getSpanAttributes()
$span_attributes['data-search-pages-type'] = $this->getPagesType();
}
-
if ($this->configHelper->getFlag(Config::XML_PATH_FACETED_SEARCH_ENABLED)) {
try {
$span_attributes['data-facets-target'] = "#clerk-search-filters";
@@ -86,7 +94,7 @@ public function getSpanAttributes()
$span_attributes['data-facets-multiselect-attributes'] = '["' . str_replace(',', '","', $multiselectAttributes) . '"]';
}
}
- } catch (Exception) {
+ } catch (Exception $ex) {
$span_attributes['data-facets-attributes'] = '["price","categories"]';
}
}
@@ -132,7 +140,6 @@ public function getTargetId()
* Determine if we should include categories and pages in search results
*
* @return string
- *
*/
public function shouldIncludeCategories()
{
@@ -140,6 +147,8 @@ public function shouldIncludeCategories()
}
/**
+ * Get categories limit
+ *
* @return mixed
*/
public function getCategories()
@@ -148,6 +157,8 @@ public function getCategories()
}
/**
+ * Get pages limit
+ *
* @return mixed
*/
public function getPages()
@@ -156,6 +167,8 @@ public function getPages()
}
/**
+ * Get pages type filter
+ *
* @return mixed
*/
public function getPagesType()
diff --git a/Block/SalesTracking.php b/Block/SalesTracking.php
index 0138d4b..c16381d 100644
--- a/Block/SalesTracking.php
+++ b/Block/SalesTracking.php
@@ -37,8 +37,7 @@ public function __construct(
Session $checkoutSession,
Grouped $productGrouped,
array $data = []
- )
- {
+ ) {
parent::__construct($context, $data);
$this->_checkoutSession = $checkoutSession;
$this->_productGrouped = $productGrouped;
diff --git a/Block/System/Config/Form/Field/information.php b/Block/System/Config/Form/Field/Information.php
similarity index 67%
rename from Block/System/Config/Form/Field/information.php
rename to Block/System/Config/Form/Field/Information.php
index 4360b58..5e1b22f 100644
--- a/Block/System/Config/Form/Field/information.php
+++ b/Block/System/Config/Form/Field/Information.php
@@ -3,11 +3,13 @@
namespace Clerk\Clerk\Block\System\Config\Form\Field;
use Magento\Backend\Block\Template\Context;
+use Magento\Config\Block\System\Config\Form\Field;
+use Magento\Framework\App\Config\ScopeConfigInterface;
+use Magento\Framework\Data\Form\Element\AbstractElement;
use Magento\Framework\Message\ManagerInterface;
use Magento\Framework\Module\ModuleListInterface;
-use Magento\Framework\App\Config\ScopeConfigInterface;
-class information extends \Magento\Config\Block\System\Config\Form\Field
+class Information extends Field
{
/**
* @var ModuleListInterface
@@ -29,15 +31,16 @@ class information extends \Magento\Config\Block\System\Config\Form\Field
*
* @param Context $context
* @param ModuleListInterface $moduleList
+ * @param ManagerInterface $messageManager
* @param ScopeConfigInterface $ScopeConfigInterface
* @param array $data
*/
public function __construct(
- Context $context,
- ModuleListInterface $moduleList,
- ManagerInterface $messageManager,
+ Context $context,
+ ModuleListInterface $moduleList,
+ ManagerInterface $messageManager,
ScopeConfigInterface $ScopeConfigInterface,
- array $data = []
+ array $data = []
) {
$this->moduleList = $moduleList;
$this->messageManager = $messageManager;
@@ -48,10 +51,10 @@ public function __construct(
/**
* Render form field
*
- * @param \Magento\Framework\Data\Form\Element\AbstractElement $element
+ * @param AbstractElement $element
* @return string
*/
- public function render(\Magento\Framework\Data\Form\Element\AbstractElement $element)
+ public function render(AbstractElement $element)
{
//Hide scope label and inheritance checkbox
$element->setCanUseWebsiteValue(false);
@@ -74,25 +77,23 @@ public function render(\Magento\Framework\Data\Form\Element\AbstractElement $ele
$html = '';
- $singlestore = $this->ScopeConfigInterface->getValue('general/single_store_mode/enabled');
+ $singlestore = $this->ScopeConfigInterface->getValue('general/single_store_mode/enabled');
if ($singlestore !== '1' && $scope === 'default') {
- $html = 'Your current scope is "Default Config", to configure Clerk settings please change scope to "website" or "store.';
- return $this->_decorateRowHtml($element, $html);
- } else {
-
- return $this->_decorateRowHtml($element, $html);
+ $html = 'Your current scope is "Default Config",' .
+ ' to configure Clerk settings please change scope to "website" or "store.';
}
+ return $this->_decorateRowHtml($element, $html);
}
/**
* Decorate field row html
*
- * @param \Magento\Framework\Data\Form\Element\AbstractElement $element
+ * @param AbstractElement $element
* @param string $html
* @return string
*/
- protected function _decorateRowHtml(\Magento\Framework\Data\Form\Element\AbstractElement $element, $html)
+ protected function _decorateRowHtml(AbstractElement $element, $html)
{
return '
' . $html . '
';
}
diff --git a/Block/System/Config/Form/Field/renderDefault.php b/Block/System/Config/Form/Field/RenderDefault.php
similarity index 66%
rename from Block/System/Config/Form/Field/renderDefault.php
rename to Block/System/Config/Form/Field/RenderDefault.php
index b004747..79936ee 100644
--- a/Block/System/Config/Form/Field/renderDefault.php
+++ b/Block/System/Config/Form/Field/RenderDefault.php
@@ -3,25 +3,28 @@
namespace Clerk\Clerk\Block\System\Config\Form\Field;
use Magento\Backend\Block\Template\Context;
+use Magento\Config\Block\System\Config\Form\Field;
use Magento\Framework\App\Config\ScopeConfigInterface;
+use Magento\Framework\Data\Form\Element\AbstractElement;
-class renderDefault extends \Magento\Config\Block\System\Config\Form\Field
+class RenderDefault extends Field
{
/**
* @var ScopeConfigInterface
*/
private $ScopeConfigInterface;
- /**
- * renderDefault field constructor.
- *
- * @param ScopeConfigInterface $ScopeConfigInterface
- * @param array $data
- */
+ /**
+ * renderDefault field constructor.
+ *
+ * @param Context $context
+ * @param ScopeConfigInterface $ScopeConfigInterface
+ * @param array $data
+ */
public function __construct(
- Context $context,
+ Context $context,
ScopeConfigInterface $ScopeConfigInterface,
- array $data = []
+ array $data = []
) {
$this->ScopeConfigInterface = $ScopeConfigInterface;
parent::__construct($context, $data);
@@ -30,10 +33,10 @@ public function __construct(
/**
* Render fieldset html
*
- * @param \Magento\Framework\Data\Form\Element\AbstractElement $element
+ * @param AbstractElement $element
* @return string
*/
- public function render(\Magento\Framework\Data\Form\Element\AbstractElement $element)
+ public function render(AbstractElement $element)
{
$currentUrl = $this->getUrl('*/*/*', ['_current' => true, '_use_rewrite' => true]);
$urlParts = explode("/", $currentUrl);
@@ -50,7 +53,7 @@ public function render(\Magento\Framework\Data\Form\Element\AbstractElement $ele
$html = '';
- $singlestore = $this->ScopeConfigInterface->getValue('general/single_store_mode/enabled');
+ $singlestore = $this->ScopeConfigInterface->getValue('general/single_store_mode/enabled');
if ($singlestore === '1' && $scope === 'default') {
return parent::render($element, $this->ScopeConfigInterface);
@@ -64,11 +67,11 @@ public function render(\Magento\Framework\Data\Form\Element\AbstractElement $ele
/**
* Decorate field row html
*
- * @param \Magento\Framework\Data\Form\Element\AbstractElement $element
+ * @param AbstractElement $element
* @param string $html
* @return string
*/
- protected function _decorateRowHtml(\Magento\Framework\Data\Form\Element\AbstractElement $element, $html)
+ protected function _decorateRowHtml(AbstractElement $element, $html)
{
return '' . $html . '
';
}
diff --git a/Block/System/Config/Form/Field/Version.php b/Block/System/Config/Form/Field/Version.php
index 5e01b36..073a5af 100644
--- a/Block/System/Config/Form/Field/Version.php
+++ b/Block/System/Config/Form/Field/Version.php
@@ -3,10 +3,12 @@
namespace Clerk\Clerk\Block\System\Config\Form\Field;
use Magento\Backend\Block\Template\Context;
+use Magento\Config\Block\System\Config\Form\Field;
+use Magento\Framework\Data\Form\Element\AbstractElement;
use Magento\Framework\Message\ManagerInterface;
use Magento\Framework\Module\ModuleListInterface;
-class Version extends \Magento\Config\Block\System\Config\Form\Field
+class Version extends Field
{
/**
* @var ModuleListInterface
@@ -24,13 +26,14 @@ class Version extends \Magento\Config\Block\System\Config\Form\Field
*
* @param Context $context
* @param ModuleListInterface $moduleList
+ * @param ManagerInterface $messageManager
* @param array $data
*/
public function __construct(
- Context $context,
+ Context $context,
ModuleListInterface $moduleList,
- ManagerInterface $messageManager,
- array $data = []
+ ManagerInterface $messageManager,
+ array $data = []
) {
$this->moduleList = $moduleList;
$this->messageManager = $messageManager;
@@ -41,10 +44,10 @@ public function __construct(
/**
* Render form field
*
- * @param \Magento\Framework\Data\Form\Element\AbstractElement $element
+ * @param AbstractElement $element
* @return string
*/
- public function render(\Magento\Framework\Data\Form\Element\AbstractElement $element)
+ public function render(AbstractElement $element)
{
//Hide scope label and inheritance checkbox
$element->setCanUseWebsiteValue(false);
@@ -58,29 +61,12 @@ public function render(\Magento\Framework\Data\Form\Element\AbstractElement $ele
/**
* Get installed version
*
- * @param \Magento\Framework\Data\Form\Element\AbstractElement $element
+ * @param AbstractElement $element
* @return string
*/
- protected function _getElementHtml(\Magento\Framework\Data\Form\Element\AbstractElement $element)
+ protected function _getElementHtml(AbstractElement $element)
{
- $modules = $this->moduleList->getAll();
-
- // $modules_for_warning = [
- // 'Clerk_Clerk' => ['message' => 'This module can interfere with how we inject our instant search.', 'link' => 'https://clerk.io']
- // ];
-
- // foreach ($modules as $name => $module) {
-
- // if (array_key_exists($name, $modules_for_warning)) {
-
- // $this->messageManager->addWarning(__('Warning: '.$name.' is installed. '.$modules_for_warning[$name]['message'].'. Read more here'));
-
- // }
- // }
-
- //Get installed module version
$moduleInfo = $this->moduleList->getOne('Clerk_Clerk');
-
return $moduleInfo['setup_version'];
}
}
diff --git a/Block/Tracking.php b/Block/Tracking.php
index 682991f..7166329 100644
--- a/Block/Tracking.php
+++ b/Block/Tracking.php
@@ -20,14 +20,34 @@
class Tracking extends Template
{
+ /**
+ * @var FormKey
+ */
protected $formKey;
+ /**
+ * @var Currency
+ */
protected $_currency;
+ /**
+ * @var StoreManagerInterface
+ */
protected $_storeManager;
+ /**
+ * @var Session
+ */
protected $_customerSession;
+ /**
+ * @param ConfigHelper $configHelper
+ * @param Context $context
+ * @param FormKey $formKey
+ * @param Currency $_currency
+ * @param StoreManagerInterface $_storeManager
+ * @param Session $_customerSession
+ */
public function __construct(
ConfigHelper $configHelper,
Context $context,
@@ -35,8 +55,7 @@ public function __construct(
Currency $_currency,
StoreManagerInterface $_storeManager,
Session $_customerSession
- )
- {
+ ) {
parent::__construct($context);
$this->formKey = $formKey;
$this->_currency = $_currency;
@@ -45,8 +64,9 @@ public function __construct(
$this->configHelper = $configHelper;
}
-
/**
+ * Get customer email
+ *
* @return string
*/
public function getCustomerEmail()
@@ -56,6 +76,7 @@ public function getCustomerEmail()
$customerData = $this->_customerSession->getCustomer();
$email = $customerData->getEmail();
} catch (Exception $ex) {
+ return $email;
}
return $email;
}
@@ -70,6 +91,11 @@ public function getPublicKey()
return $this->configHelper->getValue(Config::XML_PATH_PUBLIC_KEY);
}
+ /**
+ * Get the scope language string
+ *
+ * @return mixed
+ */
public function getLanguage()
{
return $this->configHelper->getValue(Config::XML_PATH_LANGUAGE);
@@ -78,6 +104,7 @@ public function getLanguage()
/**
* Get collect emails
*
+ * @param bool $as_bool
* @return string
*/
public function getCollectionEmails($as_bool = false)
@@ -85,7 +112,7 @@ public function getCollectionEmails($as_bool = false)
if ($as_bool) {
return $this->configHelper->getFlag(Config::XML_PATH_PRODUCT_SYNCHRONIZATION_COLLECT_EMAILS);
}
- return ($this->configHelper->getFlag(Config::XML_PATH_PRODUCT_SYNCHRONIZATION_COLLECT_EMAILS) ? 'true' : 'false');
+ return $this->configHelper->getFlag(Config::XML_PATH_PRODUCT_SYNCHRONIZATION_COLLECT_EMAILS) ? 'true' : 'false';
}
/**
@@ -95,19 +122,18 @@ public function getCollectionEmails($as_bool = false)
*/
public function getCollectionBaskets()
{
- return ($this->configHelper->getValue(Config::XML_PATH_PRODUCT_SYNCHRONIZATION_COLLECT_BASKETS)) ? "true" : "false";
+ return $this->configHelper->getValue(Config::XML_PATH_PRODUCT_SYNCHRONIZATION_COLLECT_BASKETS) ? "true" : "false";
}
/**
- * @return mixed|string
+ * Get context FormKey
+ *
+ * @return string
* @throws LocalizedException
*/
public function getFormKey()
{
- if (array_key_exists('form_key', $_COOKIE)) {
- return $_COOKIE['form_key'];
- }
- return $this->formKey->getFormKey();
+ return !empty($_COOKIE) && array_key_exists('form_key', $_COOKIE) ? $_COOKIE['form_key'] : $this->formKey->getFormKey();
}
/**
@@ -181,13 +207,15 @@ public function getCurrentCurrencySymbol()
}
/**
+ * Get all enabled currency rates
+ *
* @return array
* @throws NoSuchEntityException
*/
public function getAllCurrencyRates()
{
$currency_codes = $this->getAllowedCurrencies();
- $currency_rates_array = array();
+ $currency_rates_array = [];
foreach ($currency_codes as $key => $code) {
$currency_rates_array[$code] = $this->getCurrencyRateFromIso($code);
}
@@ -223,6 +251,8 @@ public function getCurrencyRateFromIso($currency_iso = null)
}
/**
+ * Get clerk.js custom URL
+ *
* @return string
* @throws NoSuchEntityException
*/
@@ -233,6 +263,8 @@ public function getClerkJSLink()
}
/**
+ * Get handleized version of the store name
+ *
* @return string
* @throws NoSuchEntityException
*/
diff --git a/Block/Widget/Content.php b/Block/Widget/Content.php
index 9acd727..0b5c7bd 100644
--- a/Block/Widget/Content.php
+++ b/Block/Widget/Content.php
@@ -9,7 +9,6 @@
use Magento\Framework\Registry;
use Magento\Framework\View\Element\Template;
use Magento\Framework\View\Element\Template\Context;
-use Magento\Store\Model\ScopeInterface;
use Magento\Widget\Block\BlockInterface;
class Content extends Template implements BlockInterface
@@ -38,8 +37,7 @@ public function __construct(
Registry $registry,
Cart $cart,
array $data = []
- )
- {
+ ) {
parent::__construct($context, $data);
$this->registry = $registry;
$this->cart = $cart;
@@ -47,10 +45,17 @@ public function __construct(
$this->setTemplate('Clerk_Clerk::widget.phtml');
}
+ /**
+ * Generate HTML elements for embeds
+ *
+ * @return string
+ */
public function getEmbeds()
{
$contents = $this->getContent();
-
+ if ($contents) {
+ $contents = explode(',', $contents);
+ }
if ($this->getType() === 'cart') {
$contents = $this->getCartContents();
}
@@ -64,13 +69,10 @@ public function getEmbeds()
}
$output = '';
-
- if ($contents) {
- $contents_array = explode(',', $contents);
- } else {
- $contents_array = [0 => ''];
+ if(empty($contents)){
+ return $output;
}
- foreach ($contents_array as $content) {
+ foreach ($contents as $content) {
$output .= $this->getHtmlForContent(str_replace(' ', '', $content));
}
@@ -80,74 +82,44 @@ public function getEmbeds()
/**
* Get product ids from cart
*
- * @return mixed
+ * @return string[]
*/
protected function getCartContents()
{
-
- if ($this->_storeManager->isSingleStoreMode()) {
- $scope = 'default';
- $scope_id = '0';
- } else {
- $scope = ScopeInterface::SCOPE_STORE;
- $scope_id = $this->_storeManager->getStore()->getId();
- }
-
- return $this->_scopeConfig->getValue(Config::XML_PATH_CART_CONTENT, $scope, $scope_id);
+ return $this->configHelper->getTemplates(Config::XML_PATH_CART_CONTENT);
}
/**
* Get content for category page slider
*
- * @return mixed
+ * @return string[]
*/
protected function getCategoryContents()
{
-
- if ($this->_scopeConfig->getValue('general/single_store_mode/enabled') == 1) {
- $scope = 'default';
- $scope_id = '0';
- } else {
- $scope = ScopeInterface::SCOPE_STORE;
- $scope_id = $this->_storeManager->getStore()->getId();
- }
-
- return $this->_scopeConfig->getValue(Config::XML_PATH_CATEGORY_CONTENT, $scope, $scope_id);
+ return $this->configHelper->getTemplates(Config::XML_PATH_CATEGORY_CONTENT);
}
/**
* Get content for product page slider
*
- * @return mixed
+ * @return string[]
*/
protected function getProductContents()
{
-
- if ($this->_scopeConfig->getValue('general/single_store_mode/enabled') == 1) {
- $scope = 'default';
- $scope_id = '0';
- } else {
- $scope = ScopeInterface::SCOPE_STORE;
- $scope_id = $this->_storeManager->getStore()->getId();
- }
-
- return $this->_scopeConfig->getValue(Config::XML_PATH_PRODUCT_CONTENT, $scope, $scope_id);
+ return $this->configHelper->getTemplates(Config::XML_PATH_PRODUCT_CONTENT);
}
+ /**
+ * Get HTML tag for clerk elements
+ *
+ * @param $content
+ * @return string
+ */
private function getHtmlForContent($content)
{
-
- if ($this->_storeManager->isSingleStoreMode()) {
- $scope = 'default';
- $scope_id = '0';
- } else {
- $scope = ScopeInterface::SCOPE_STORE;
- $scope_id = $this->_storeManager->getStore()->getId();
- }
-
- $filter_category = $this->_scopeConfig->getValue(Config::XML_PATH_CATEGORY_FILTER_DUPLICATES, $scope, $scope_id);
- $filter_product = $this->_scopeConfig->getValue(Config::XML_PATH_PRODUCT_FILTER_DUPLICATES, $scope, $scope_id);
- $filter_cart = $this->_scopeConfig->getValue(Config::XML_PATH_CART_FILTER_DUPLICATES, $scope, $scope_id);
+ $filter_category = $this->configHelper->getValue(Config::XML_PATH_CATEGORY_FILTER_DUPLICATES);
+ $filter_product = $this->configHelper->getValue(Config::XML_PATH_PRODUCT_FILTER_DUPLICATES);
+ $filter_cart = $this->configHelper->getValue(Config::XML_PATH_CART_FILTER_DUPLICATES);
static $product_contents = 0;
static $cart_contents = 0;
@@ -156,7 +128,7 @@ private function getHtmlForContent($content)
$output = ' 'clerk',
- 'data-template' => '@' . $content,
+ 'data-template' => '@' . $content
];
if ($this->getProductId()) {
@@ -172,18 +144,7 @@ private function getHtmlForContent($content)
$spanAttributes['data-product'] = $productId;
}
if ($filter_product) {
- $unique_class = "clerk_" . (string)$product_contents;
- $spanAttributes['class'] = 'clerk ' . $unique_class;
- if ($product_contents > 0) {
- $filter_string = '';
- for ($i = 0; $i < $product_contents; $i++) {
- if ($i > 0) {
- $filter_string .= ', ';
- }
- $filter_string .= '.clerk_' . strval($i);
- }
- $spanAttributes['data-exclude-from'] = $filter_string;
- }
+ $spanAttributes = $this->getAttributes($product_contents, $spanAttributes);
}
}
@@ -199,54 +160,21 @@ private function getHtmlForContent($content)
$spanAttributes['data-category'] = $categoryId;
}
if ($filter_category) {
- $unique_class = "clerk_" . (string)$category_contents;
- $spanAttributes['class'] = 'clerk ' . $unique_class;
- if ($category_contents > 0) {
- $filter_string = '';
- for ($i = 0; $i < $category_contents; $i++) {
- if ($i > 0) {
- $filter_string .= ', ';
- }
- $filter_string .= '.clerk_' . strval($i);
- }
- $spanAttributes['data-exclude-from'] = $filter_string;
- }
+ $spanAttributes = $this->getAttributes($category_contents, $spanAttributes);
}
}
if ($this->getType() === 'cart') {
$spanAttributes['data-products'] = json_encode($this->getCartProducts());
if ($filter_cart) {
- $unique_class = "clerk_" . (string)$cart_contents;
- $spanAttributes['class'] = 'clerk ' . $unique_class;
- if ($cart_contents > 0) {
- $filter_string = '';
- for ($i = 0; $i < $cart_contents; $i++) {
- if ($i > 0) {
- $filter_string .= ', ';
- }
- $filter_string .= '.clerk_' . strval($i);
- }
- $spanAttributes['data-exclude-from'] = $filter_string;
- }
+ $spanAttributes = $this->getAttributes($cart_contents, $spanAttributes);
}
}
if ($this->getType() === 'category') {
$spanAttributes['data-category'] = $this->getCurrentCategory();
if ($filter_category) {
- $unique_class = "clerk_" . (string)$category_contents;
- $spanAttributes['class'] = 'clerk ' . $unique_class;
- if ($category_contents > 0) {
- $filter_string = '';
- for ($i = 0; $i < $category_contents; $i++) {
- if ($i > 0) {
- $filter_string .= ', ';
- }
- $filter_string .= '.clerk_' . strval($i);
- }
- $spanAttributes['data-exclude-from'] = $filter_string;
- }
+ $spanAttributes = $this->getAttributes($category_contents, $spanAttributes);
}
}
@@ -254,18 +182,7 @@ private function getHtmlForContent($content)
$spanAttributes['data-products'] = json_encode([$this->getCurrentProduct()]);
$spanAttributes['data-product'] = $this->getCurrentProduct();
if ($filter_product) {
- $unique_class = "clerk_" . (string)$product_contents;
- $spanAttributes['class'] = 'clerk ' . $unique_class;
- if ($product_contents > 0) {
- $filter_string = '';
- for ($i = 0; $i < $product_contents; $i++) {
- if ($i > 0) {
- $filter_string .= ', ';
- }
- $filter_string .= '.clerk_' . strval($i);
- }
- $spanAttributes['data-exclude-from'] = $filter_string;
- }
+ $spanAttributes = $this->getAttributes($product_contents, $spanAttributes);
}
}
@@ -283,19 +200,55 @@ private function getHtmlForContent($content)
}
/**
+ * Set element classes
+ *
+ * @param int $product_contents
+ * @param array $span_attributes
* @return array
*/
- protected function getCartProducts()
+ public function getAttributes(int $product_contents, array $span_attributes): array
+ {
+ $unique_class = "clerk_" . $product_contents;
+ $span_attributes['class'] = 'clerk ' . $unique_class;
+ if ($product_contents > 0) {
+ $filter_string = $this->getFilterClassString($product_contents);
+ $span_attributes['data-exclude-from'] = $filter_string;
+ }
+ return $span_attributes;
+ }
+
+ /**
+ * Get filter class
+ *
+ * @param int $product_contents
+ * @return string
+ */
+ public function getFilterClassString(int $product_contents): string
{
- $products = array_values($this->cart->getProductIds());
+ $filter_string = '';
+ for ($i = 0; $i < $product_contents; $i++) {
+ if ($i > 0) {
+ $filter_string .= ', ';
+ }
+ $filter_string .= '.clerk_' . $i;
+ }
+ return $filter_string;
+ }
- return $products;
+ /**
+ * Get cart ids
+ *
+ * @return array
+ */
+ protected function getCartProducts()
+ {
+ return array_values($this->cart->getProductIds());
}
/**
* Get current category id
*
- * @return mixed
+ * @return int|void
*/
protected function getCurrentCategory()
{
@@ -309,7 +262,7 @@ protected function getCurrentCategory()
/**
* Get current product id
*
- * @return mixed
+ * @return int|void
*/
protected function getCurrentProduct()
{
@@ -320,197 +273,29 @@ protected function getCurrentProduct()
}
}
- /**
- * Get attributes for Clerk span
- *
- * @return string
- * @throws LocalizedException
- */
- public function getSpanAttributes()
- {
-
- if ($this->_scopeConfig->getValue('general/single_store_mode/enabled') == 1) {
- $scope = 'default';
- $scope_id = '0';
- } else {
- $scope = ScopeInterface::SCOPE_STORE;
- $scope_id = $this->_storeManager->getStore()->getId();
- }
-
- $filter_category = $this->_scopeConfig->getValue(Config::XML_PATH_CATEGORY_FILTER_DUPLICATES, $scope, $scope_id);
- $filter_product = $this->_scopeConfig->getValue(Config::XML_PATH_PRODUCT_FILTER_DUPLICATES, $scope, $scope_id);
- $filter_cart = $this->_scopeConfig->getValue(Config::XML_PATH_CART_FILTER_DUPLICATES, $scope, $scope_id);
-
- static $product_contents = 0;
- static $cart_contents = 0;
- static $category_contents = 0;
-
- $output = ' 'clerk',
- 'data-template' => '@' . $this->getContents(),
- ];
-
- if ($this->getProductId()) {
- $value = explode('/', $this->getProductId());
- $productId = false;
-
- if (isset($value[0]) && isset($value[1]) && $value[0] == 'product') {
- $productId = $value[1];
- }
-
- if ($productId) {
- $spanAttributes['data-products'] = json_encode([$productId]);
- $spanAttributes['data-product'] = $productId;
- }
- if ($filter_product) {
- $unique_class = "clerk_" . (string)$product_contents;
- $spanAttributes['class'] = 'clerk ' . $unique_class;
- if ($product_contents > 0) {
- $filter_string = '';
- for ($i = 0; $i < $product_contents; $i++) {
- if ($i > 0) {
- $filter_string .= ', ';
- }
- $filter_string .= '.clerk_' . strval($i);
- }
- $spanAttributes['data-exclude-from'] = $filter_string;
- }
- }
- }
-
- if ($this->getCategoryId()) {
- $value = explode('/', $this->getCategoryId());
- $categoryId = false;
-
- if (isset($value[0]) && isset($value[1]) && $value[0] == 'category') {
- $categoryId = $value[1];
- }
-
- if ($categoryId) {
- $spanAttributes['data-category'] = $categoryId;
- }
- if ($filter_category) {
- $unique_class = "clerk_" . (string)$category_contents;
- $spanAttributes['class'] = 'clerk ' . $unique_class;
- if ($category_contents > 0) {
- $filter_string = '';
- for ($i = 0; $i < $category_contents; $i++) {
- if ($i > 0) {
- $filter_string .= ', ';
- }
- $filter_string .= '.clerk_' . strval($i);
- }
- $spanAttributes['data-exclude-from'] = $filter_string;
- }
- }
- }
-
- if ($this->getType() === 'cart') {
- $spanAttributes['data-products'] = json_encode($this->getCartProducts());
- $spanAttributes['data-template'] = '@' . $this->getCartContents();
- if ($filter_cart) {
- $unique_class = "clerk_" . (string)$cart_contents;
- $spanAttributes['class'] = 'clerk ' . $unique_class;
- if ($cart_contents > 0) {
- $filter_string = '';
- for ($i = 0; $i < $cart_contents; $i++) {
- if ($i > 0) {
- $filter_string .= ', ';
- }
- $filter_string .= '.clerk_' . strval($i);
- }
- $spanAttributes['data-exclude-from'] = $filter_string;
- }
- }
- }
-
- if ($this->getType() === 'category') {
- $spanAttributes['data-category'] = $this->getCurrentCategory();
- $spanAttributes['data-template'] = '@' . $this->getCategoryContents();
- if ($filter_category) {
- $unique_class = "clerk_" . (string)$category_contents;
- $spanAttributes['class'] = 'clerk ' . $unique_class;
- if ($category_contents > 0) {
- $filter_string = '';
- for ($i = 0; $i < $category_contents; $i++) {
- if ($i > 0) {
- $filter_string .= ', ';
- }
- $filter_string .= '.clerk_' . strval($i);
- }
- $spanAttributes['data-exclude-from'] = $filter_string;
- }
- }
- }
-
- if ($this->getType() === 'product') {
- $spanAttributes['data-products'] = json_encode([$this->getCurrentProduct()]);
- $spanAttributes['data-product'] = $this->getCurrentProduct();
- $spanAttributes['data-template'] = '@' . $this->getProductContents();
- if ($filter_product) {
- $unique_class = "clerk_" . (string)$product_contents;
- $spanAttributes['class'] = 'clerk ' . $unique_class;
- if ($product_contents > 0) {
- $filter_string = '';
- for ($i = 0; $i < $product_contents; $i++) {
- if ($i > 0) {
- $filter_string .= ', ';
- }
- $filter_string .= '.clerk_' . strval($i);
- }
- $spanAttributes['data-exclude-from'] = $filter_string;
- }
- }
- }
-
- foreach ($spanAttributes as $attribute => $value) {
- $output .= ' ' . $attribute . '=\'' . $value . '\'';
- }
-
- $output .= '>';
-
- $product_contents++;
- $cart_contents++;
- $category_contents++;
-
- return $output;
- }
-
/**
* Determine if we should show any output
*
- * @return string
+ * @return string|void
* @throws LocalizedException
*/
protected function _toHtml()
{
- if ($this->_scopeConfig->getValue('general/single_store_mode/enabled') == 1) {
- $scope = 'default';
- $scope_id = '0';
- } else {
- $scope = ScopeInterface::SCOPE_STORE;
- $scope_id = $this->_storeManager->getStore()->getId();
- }
-
if ($this->getType() === 'cart') {
- if (!$this->_scopeConfig->isSetFlag(Config::XML_PATH_CART_ENABLED, $scope, $scope_id)) {
+ if (!$this->configHelper->getFlag(Config::XML_PATH_CART_ENABLED)) {
return;
}
}
-
if ($this->getType() === 'category') {
- if (!$this->_scopeConfig->isSetFlag(Config::XML_PATH_CATEGORY_ENABLED, $scope, $scope_id)) {
+ if (!$this->configHelper->getFlag(Config::XML_PATH_CATEGORY_ENABLED)) {
return;
}
}
-
if ($this->getType() === 'product') {
- if (!$this->_scopeConfig->isSetFlag(Config::XML_PATH_PRODUCT_ENABLED, $scope, $scope_id)) {
+ if (!$this->configHelper->getFlag(Config::XML_PATH_PRODUCT_ENABLED)) {
return;
}
}
-
return parent::_toHtml();
}
}
diff --git a/Controller/AbstractAction.php b/Controller/AbstractAction.php
index 3987f43..b0ab7d3 100644
--- a/Controller/AbstractAction.php
+++ b/Controller/AbstractAction.php
@@ -244,7 +244,7 @@ public function execute()
/**
* Prepare collection
*
- * @return object|null
+ * @return object|void
* @throws FileSystemException
*/
protected function prepareCollection()
@@ -257,7 +257,6 @@ protected function prepareCollection()
$collection->addFieldToSelect('*');
if ($this->start_date) {
-
$collection->setPageSize($this->limit)
->setCurPage($this->page)
->addAttributeToFilter('created_at', ['from' => $this->start_date, 'to' => $this->end_date])
@@ -277,14 +276,13 @@ protected function prepareCollection()
$this->clerkLogger->error('prepareCollection ERROR', ['error' => $e->getMessage()]);
}
- return null;
}
/**
* Dispatch request
*
* @param RequestInterface $request
- * @return ResponseInterface|null
+ * @return ResponseInterface|void
* @throws FileSystemException
* @noinspection PhpPossiblePolymorphicInvocationInspection
*/
@@ -331,18 +329,13 @@ public function dispatch(RequestInterface $request)
return parent::dispatch($request);
} catch (Exception $e) {
-
$this->clerkLogger->error('Validating API Keys ERROR', ['error' => $e->getMessage()]);
-
}
-
- return null;
}
/**
* @param $key
- * @return mixed|null
- * @throws FileSystemException
+ * @return mixed|void
*/
public function getRequestBodyParam($key)
{
@@ -355,17 +348,12 @@ public function getRequestBodyParam($key)
}
} catch (Exception $e) {
-
$this->clerkLogger->error('Getting Request Body ERROR', ['error' => $e->getMessage()]);
-
}
-
- return null;
}
/**
* @return array
- * @throws FileSystemException
*/
private function identifyScope()
{
@@ -402,27 +390,20 @@ private function identifyScope()
/**
* Verify public & private key
*
- * @return int|null
- * @throws FileSystemException
+ * @return int|void
*/
private function verifyWebsiteKeys()
{
-
try {
-
$websiteids = $this->getWebsites();
foreach ($websiteids as $scopeID) {
if ($this->timingSafeEquals($this->getPublicWebsiteKey($scopeID), $this->publicKey)) {
return $scopeID;
}
}
-
} catch (Exception $e) {
-
$this->clerkLogger->error('verifyKeys ERROR', ['error' => $e->getMessage()]);
-
}
- return null;
}
public function getWebsites()
@@ -466,30 +447,25 @@ private function timingSafeEquals(string $safe, string $user)
* Get public website key
*
* @param $scopeID
- * @return string|null
- * @throws FileSystemException
+ * @return string|void
*/
private function getPublicWebsiteKey($scopeID)
{
try {
-
return $this->scopeConfig->getValue(
Config::XML_PATH_PUBLIC_KEY,
ScopeInterface::SCOPE_WEBSITES,
$scopeID
);
-
} catch (Exception $e) {
$this->clerkLogger->error('getPublicKey ERROR', ['error' => $e->getMessage()]);
}
- return null;
}
/**
* Verify public & private key
*
- * @return int|null
- * @throws FileSystemException
+ * @return int|void
*/
private function verifyKeys()
{
@@ -508,7 +484,6 @@ private function verifyKeys()
$this->clerkLogger->error('verifyKeys ERROR', ['error' => $e->getMessage()]);
}
- return null;
}
public function getStores()
@@ -517,11 +492,10 @@ public function getStores()
}
/**
- * Get public store key
+ * Get the public store key
*
* @param $scopeID
- * @return string|null
- * @throws FileSystemException
+ * @return string|void
*/
private function getPublicKey($scopeID)
{
@@ -538,14 +512,12 @@ private function getPublicKey($scopeID)
$this->clerkLogger->error('getPublicKey ERROR', ['error' => $e->getMessage()]);
}
- return null;
}
/**
* Verify public & private key
*
- * @return int|null
- * @throws FileSystemException
+ * @return int|void
*/
private function verifyDefaultKeys()
{
@@ -561,15 +533,13 @@ private function verifyDefaultKeys()
$this->clerkLogger->error('verifyKeys ERROR', ['error' => $e->getMessage()]);
}
- return null;
}
/**
- * Get public store key
+ * Get the public store key
*
* @param $scopeID
- * @return string|null
- * @throws FileSystemException
+ * @return string|void
*/
private function getPublicDefaultKey($scopeID)
{
@@ -586,7 +556,6 @@ private function getPublicDefaultKey($scopeID)
$this->clerkLogger->error('getPublicKey ERROR', ['error' => $e->getMessage()]);
}
- return null;
}
/**
@@ -617,7 +586,6 @@ private function authorize($scope_info)
}
$private_key = $this->getPrivateKey($scope_info['scope'], $scope_info['scope_id']);
return $this->timingSafeEquals($private_key, $this->privateKey);
-
}
/**
@@ -650,7 +618,6 @@ public function validateJwt()
}
return true;
-
}
/**
@@ -664,7 +631,7 @@ private function getHeaderToken()
$token = '';
$auth_header = $this->requestApi->getHeader('X-Clerk-Authorization');
- if (null == $auth_header && !is_string($auth_header)) {
+ if (!is_string($auth_header)) {
return "";
}
@@ -684,12 +651,11 @@ private function getHeaderToken()
}
/**
- * Get private store key
+ * Get the private store key
*
* @param string $scope
* @param int $scope_id
- * @return string|null
- * @throws FileSystemException
+ * @return string|void
*/
private function getPrivateKey($scope, $scope_id)
{
@@ -702,16 +668,15 @@ private function getPrivateKey($scope, $scope_id)
);
} catch (Exception $e) {
-
$this->clerkLogger->error('getPrivateKey ERROR', ['error' => $e->getMessage()]);
-
}
- return null;
}
/**
* Parse request arguments
- * @throws FileSystemException
+ *
+ * @param RequestInterface $request
+ * @return void
*/
protected function getArguments(RequestInterface $request)
{
@@ -751,7 +716,7 @@ protected function getArguments(RequestInterface $request)
$this->order = $request->getParam('order') === 'desc' ? Collection::SORT_ORDER_DESC : Collection::SORT_ORDER_ASC;
/**
- * Explode fields on , and filter out "empty" entries
+ * Explode fields on ',' and filter out "empty" entries
*/
$fields = $request->getParam('fields');
$this->fields = $fields ? array_filter(explode(',', $fields), 'strlen') : $this->getDefaultFields();
@@ -764,9 +729,7 @@ protected function getArguments(RequestInterface $request)
}
} catch (Exception $e) {
-
$this->clerkLogger->error('getArguments ERROR', ['error' => $e->getMessage()]);
-
}
}
@@ -783,23 +746,17 @@ protected function getDefaultFields()
/**
* Get mapped field name
*
- * @param $field
+ * @param string $field
* @return mixed
- * @throws FileSystemException
*/
protected function getFieldName($field)
{
-
try {
-
if (isset($this->fieldMap[$field])) {
return $this->fieldMap[$field];
}
-
} catch (Exception $e) {
-
$this->clerkLogger->error('Getting Field Name ERROR', ['error' => $e->getMessage()]);
-
}
return $field;
}
diff --git a/Controller/Adminhtml/Dashboard/Audience.php b/Controller/Adminhtml/Dashboard/Audience.php
index 91d840a..494f210 100644
--- a/Controller/Adminhtml/Dashboard/Audience.php
+++ b/Controller/Adminhtml/Dashboard/Audience.php
@@ -2,29 +2,33 @@
namespace Clerk\Clerk\Controller\Adminhtml\Dashboard;
-use Magento\Backend\App\Action;
-use Magento\Framework\App\ResponseInterface;
use Clerk\Clerk\Controller\Logger\ClerkLogger;
+use Exception;
+use Magento\Backend\App\Action;
+use Magento\Backend\App\Action\Context;
+use Magento\Backend\Model\View\Result\Page;
+use Magento\Framework\View\Result\PageFactory;
class Audience extends Action
{
/**
- * @var
+ * @var ClerkLogger
*/
protected $clerk_logger;
/**
- * @var \Magento\Framework\View\Result\PageFactory
+ * @var PageFactory
*/
protected $resultPageFactory;
/**
- * @param \Magento\Backend\App\Action\Context $context
- * @param \Magento\Framework\View\Result\PageFactory $resultPageFactory
+ * @param Context $context
+ * @param PageFactory $resultPageFactory
+ * @param ClerkLogger $clerk_logger
*/
public function __construct(
- \Magento\Backend\App\Action\Context $context,
- \Magento\Framework\View\Result\PageFactory $resultPageFactory,
+ Context $context,
+ PageFactory $resultPageFactory,
ClerkLogger $clerk_logger
) {
parent::__construct($context);
@@ -33,13 +37,15 @@ public function __construct(
}
/**
- * @return \Magento\Backend\Model\View\Result\Page
+ * Execute page
+ *
+ * @return Page|void
*/
public function execute()
{
try {
- /** @var \Magento\Backend\Model\View\Result\Page $resultPage */
+ /** @var Page $resultPage */
$resultPage = $this->resultPageFactory->create();
$resultPage->setActiveMenu('Clerk_Clerk::report_clerkroot_audience_insights');
$resultPage->addBreadcrumb(__('Clerk.io - Audience Insights'), __('Clerk.io - Audience Insights'));
@@ -47,7 +53,7 @@ public function execute()
return $resultPage;
- } catch (\Exception $e) {
+ } catch (Exception $e) {
$this->clerk_logger->error('Audience execute ERROR', ['error' => $e->getMessage()]);
diff --git a/Controller/Adminhtml/Dashboard/Email.php b/Controller/Adminhtml/Dashboard/Email.php
index f0f37b2..a3fecfe 100644
--- a/Controller/Adminhtml/Dashboard/Email.php
+++ b/Controller/Adminhtml/Dashboard/Email.php
@@ -2,29 +2,33 @@
namespace Clerk\Clerk\Controller\Adminhtml\Dashboard;
-use Magento\Backend\App\Action;
-use Magento\Framework\App\ResponseInterface;
use Clerk\Clerk\Controller\Logger\ClerkLogger;
+use Exception;
+use Magento\Backend\App\Action;
+use Magento\Backend\App\Action\Context;
+use Magento\Backend\Model\View\Result\Page;
+use Magento\Framework\View\Result\PageFactory;
class Email extends Action
{
/**
- * @var
+ * @var ClerkLogger
*/
protected $clerk_logger;
/**
- * @var \Magento\Framework\View\Result\PageFactory
+ * @var PageFactory
*/
protected $resultPageFactory;
/**
- * @param \Magento\Backend\App\Action\Context $context
- * @param \Magento\Framework\View\Result\PageFactory $resultPageFactory
+ * @param Context $context
+ * @param PageFactory $resultPageFactory
+ * @param ClerkLogger $clerk_logger
*/
public function __construct(
- \Magento\Backend\App\Action\Context $context,
- \Magento\Framework\View\Result\PageFactory $resultPageFactory,
+ Context $context,
+ PageFactory $resultPageFactory,
ClerkLogger $clerk_logger
) {
parent::__construct($context);
@@ -33,13 +37,15 @@ public function __construct(
}
/**
- * @return \Magento\Backend\Model\View\Result\Page
+ * Page execute function
+ *
+ * @return Page|void
*/
public function execute()
{
try {
- /** @var \Magento\Backend\Model\View\Result\Page $resultPage */
+ /** @var Page $resultPage */
$resultPage = $this->resultPageFactory->create();
$resultPage->setActiveMenu('Clerk_Clerk::report_clerkroot_email_insights');
$resultPage->addBreadcrumb(__('Clerk.io - Email Insights'), __('Clerk.io - Email Insights'));
@@ -47,7 +53,7 @@ public function execute()
return $resultPage;
- } catch (\Exception $e) {
+ } catch (Exception $e) {
$this->clerk_logger->error('Email execute ERROR', ['error' => $e->getMessage()]);
diff --git a/Controller/Adminhtml/Dashboard/Index.php b/Controller/Adminhtml/Dashboard/Index.php
index c67e171..0d7ad0e 100644
--- a/Controller/Adminhtml/Dashboard/Index.php
+++ b/Controller/Adminhtml/Dashboard/Index.php
@@ -2,29 +2,33 @@
namespace Clerk\Clerk\Controller\Adminhtml\Dashboard;
-use Magento\Backend\App\Action;
-use Magento\Framework\App\ResponseInterface;
use Clerk\Clerk\Controller\Logger\ClerkLogger;
+use Exception;
+use Magento\Backend\App\Action;
+use Magento\Backend\App\Action\Context;
+use Magento\Backend\Model\View\Result\Page;
+use Magento\Framework\View\Result\PageFactory;
class Index extends Action
{
/**
- * @var
+ * @var ClerkLogger
*/
protected $clerk_logger;
/**
- * @var \Magento\Framework\View\Result\PageFactory
+ * @var PageFactory
*/
protected $resultPageFactory;
/**
- * @param \Magento\Backend\App\Action\Context $context
- * @param \Magento\Framework\View\Result\PageFactory $resultPageFactory
+ * @param Context $context
+ * @param PageFactory $resultPageFactory
+ * @param ClerkLogger $clerk_logger
*/
public function __construct(
- \Magento\Backend\App\Action\Context $context,
- \Magento\Framework\View\Result\PageFactory $resultPageFactory,
+ Context $context,
+ PageFactory $resultPageFactory,
ClerkLogger $clerk_logger
) {
parent::__construct($context);
@@ -33,13 +37,15 @@ public function __construct(
}
/**
- * @return \Magento\Backend\Model\View\Result\Page
+ * Execute page function
+ *
+ * @return Page|void
*/
public function execute()
{
try {
- /** @var \Magento\Backend\Model\View\Result\Page $resultPage */
+ /** @var Page $resultPage */
$resultPage = $this->resultPageFactory->create();
$resultPage->setActiveMenu('Clerk_Clerk::report_clerkroot_dashboard');
$resultPage->addBreadcrumb(__('Clerk.io Dashboard'), __('Clerk.io Dashboard'));
@@ -47,7 +53,7 @@ public function execute()
return $resultPage;
- } catch (\Exception $e) {
+ } catch (Exception $e) {
$this->clerk_logger->error('Dashboard execute ERROR', ['error' => $e->getMessage()]);
diff --git a/Controller/Adminhtml/Dashboard/Recommendations.php b/Controller/Adminhtml/Dashboard/Recommendations.php
index 93f65c6..193218b 100644
--- a/Controller/Adminhtml/Dashboard/Recommendations.php
+++ b/Controller/Adminhtml/Dashboard/Recommendations.php
@@ -2,29 +2,33 @@
namespace Clerk\Clerk\Controller\Adminhtml\Dashboard;
-use Magento\Backend\App\Action;
-use Magento\Framework\App\ResponseInterface;
use Clerk\Clerk\Controller\Logger\ClerkLogger;
+use Exception;
+use Magento\Backend\App\Action;
+use Magento\Backend\App\Action\Context;
+use Magento\Backend\Model\View\Result\Page;
+use Magento\Framework\View\Result\PageFactory;
class Recommendations extends Action
{
/**
- * @var
+ * @var ClerkLogger
*/
protected $clerk_logger;
/**
- * @var \Magento\Framework\View\Result\PageFactory
+ * @var PageFactory
*/
protected $resultPageFactory;
/**
- * @param \Magento\Backend\App\Action\Context $context
- * @param \Magento\Framework\View\Result\PageFactory $resultPageFactory
+ * @param Context $context
+ * @param PageFactory $resultPageFactory
+ * @param ClerkLogger $clerk_logger
*/
public function __construct(
- \Magento\Backend\App\Action\Context $context,
- \Magento\Framework\View\Result\PageFactory $resultPageFactory,
+ Context $context,
+ PageFactory $resultPageFactory,
ClerkLogger $clerk_logger
) {
parent::__construct($context);
@@ -33,19 +37,21 @@ public function __construct(
}
/**
- * @return \Magento\Backend\Model\View\Result\Page
+ * Execute page function
+ *
+ * @return Page|void
*/
public function execute()
{
try {
- /** @var \Magento\Backend\Model\View\Result\Page $resultPage */
+ /** @var Page $resultPage */
$resultPage = $this->resultPageFactory->create();
$resultPage->setActiveMenu('Clerk_Clerk::report_clerkroot_recommendations_insights');
$resultPage->addBreadcrumb(__('Clerk.io - Recommendations Insights'), __('Clerk.io - Recommendations Insights'));
$resultPage->getConfig()->getTitle()->prepend(__('Clerk.io - Recommendations Insights'));
return $resultPage;
- } catch (\Exception $e) {
+ } catch (Exception $e) {
$this->clerk_logger->error('Recommendations execute ERROR', ['error' => $e->getMessage()]);
diff --git a/Controller/Adminhtml/Dashboard/Search.php b/Controller/Adminhtml/Dashboard/Search.php
index 14455fb..6c5053d 100644
--- a/Controller/Adminhtml/Dashboard/Search.php
+++ b/Controller/Adminhtml/Dashboard/Search.php
@@ -2,29 +2,33 @@
namespace Clerk\Clerk\Controller\Adminhtml\Dashboard;
-use Magento\Backend\App\Action;
-use Magento\Framework\App\ResponseInterface;
use Clerk\Clerk\Controller\Logger\ClerkLogger;
+use Exception;
+use Magento\Backend\App\Action;
+use Magento\Backend\App\Action\Context;
+use Magento\Backend\Model\View\Result\Page;
+use Magento\Framework\View\Result\PageFactory;
class Search extends Action
{
/**
- * @var
+ * @var ClerkLogger
*/
protected $clerk_logger;
/**
- * @var \Magento\Framework\View\Result\PageFactory
+ * @var PageFactory
*/
protected $resultPageFactory;
/**
- * @param \Magento\Backend\App\Action\Context $context
- * @param \Magento\Framework\View\Result\PageFactory $resultPageFactory
+ * @param Context $context
+ * @param PageFactory $resultPageFactory
+ * @param ClerkLogger $clerk_logger
*/
public function __construct(
- \Magento\Backend\App\Action\Context $context,
- \Magento\Framework\View\Result\PageFactory $resultPageFactory,
+ Context $context,
+ PageFactory $resultPageFactory,
ClerkLogger $clerk_logger
) {
parent::__construct($context);
@@ -33,22 +37,22 @@ public function __construct(
}
/**
- * @return \Magento\Backend\Model\View\Result\Page
+ * Execute page function
+ *
+ * @return Page|void
*/
public function execute()
{
try {
- /** @var \Magento\Backend\Model\View\Result\Page $resultPage */
+ /** @var Page $resultPage */
$resultPage = $this->resultPageFactory->create();
$resultPage->setActiveMenu('Clerk_Clerk::report_clerkroot_search_insights');
$resultPage->addBreadcrumb(__('Clerk.io - Search Insights'), __('Clerk.io - Search Insights'));
$resultPage->getConfig()->getTitle()->prepend(__('Clerk.io - Search Insights'));
return $resultPage;
- } catch (\Exception $e) {
-
+ } catch (Exception $e) {
$this->clerk_logger->error('Search execute ERROR', ['error' => $e->getMessage()]);
-
}
}
}
diff --git a/Controller/Adminhtml/Widget/Index.php b/Controller/Adminhtml/Widget/Index.php
index 270d314..d0169f8 100644
--- a/Controller/Adminhtml/Widget/Index.php
+++ b/Controller/Adminhtml/Widget/Index.php
@@ -2,24 +2,23 @@
namespace Clerk\Clerk\Controller\Adminhtml\Widget;
+use Clerk\Clerk\Controller\Logger\ClerkLogger;
use Clerk\Clerk\Model\Api;
use Clerk\Clerk\Model\Config\Source\Content;
+use Exception;
use Magento\Backend\App\Action;
-use Magento\Framework\App\ResponseInterface;
-use Magento\Framework\Data\Form;
-use Magento\Framework\Data\FormFactory;
-use Magento\Framework\Option\ArrayPool;
-use Clerk\Clerk\Controller\Logger\ClerkLogger;
-
-use Magento\Framework\Data\Form\Element\Select as FormSelect;
-use Magento\Backend\Block\Widget\Form\Renderer\Fieldset\Element as FieldElement;
+use Magento\Backend\App\Action\Context;
use Magento\Backend\Block\Widget\Form\Renderer\Fieldset as FieldSet;
+use Magento\Backend\Block\Widget\Form\Renderer\Fieldset\Element as FieldElement;
use Magento\Catalog\Block\Adminhtml\Product\Widget\Chooser as WidgetChooser;
+use Magento\Framework\Data\Form\Element\Select as FormSelect;
+use Magento\Framework\Data\FormFactory;
+use Magento\Framework\Option\ArrayPool;
class Index extends Action
{
/**
- * @var
+ * @var ClerkLogger
*/
protected $clerk_logger;
@@ -61,26 +60,27 @@ class Index extends Action
/**
* Index constructor.
*
- * @param Action\Context $context
+ * @param Context $context
* @param Api $api
* @param FormFactory $formFactory
- * @param ArrayPool $sourceModelPool
* @param FormSelect $formSelect
* @param FieldElement $fieldElement
* @param FieldSet $fieldSet
* @param WidgetChooser $widgetChooser
+ * @param ArrayPool $sourceModelPool
+ * @param ClerkLogger $clerk_logger
*/
public function __construct(
Action\Context $context,
- Api $api,
- FormFactory $formFactory,
- FormSelect $formSelect,
- FieldElement $fieldElement,
- FieldSet $fieldSet,
- WidgetChooser $widgetChooser,
- ArrayPool $sourceModelPool,
- ClerkLogger $clerk_logger
- )
+ Api $api,
+ FormFactory $formFactory,
+ FormSelect $formSelect,
+ FieldElement $fieldElement,
+ FieldSet $fieldSet,
+ WidgetChooser $widgetChooser,
+ ArrayPool $sourceModelPool,
+ ClerkLogger $clerk_logger
+ )
{
$this->api = $api;
$this->formFactory = $formFactory;
@@ -95,8 +95,9 @@ public function __construct(
}
/**
- * @return ResponseInterface|\Magento\Framework\Controller\ResultInterface|void
- * @throws \Magento\Framework\Exception\LocalizedException
+ * Block execute function
+ *
+ * @return void
*/
public function execute()
{
@@ -114,22 +115,27 @@ public function execute()
default:
$this->getInvalidResponse();
}
- } catch (\Exception $e) {
+ } catch (Exception $e) {
$this->clerk_logger->error('Widget execute ERROR', ['error' => $e->getMessage()]);
}
}
+ /**
+ * Create content response for widget
+ *
+ * @return void
+ */
public function getContentResponse()
{
try {
- /** @var Form $form */
$form = $this->formFactory->create();
$select = $this->_formSelect;
$select->setHtmlId('clerk_widget_content');
$select->setId('clerk_widget_content');
$select->setCssClass('clerk_content_select');
+ /** @noinspection PhpPossiblePolymorphicInvocationInspection */
$select->setName('parameters[content]');
$select->setValues($this->sourceModelPool->get(Content::class)->toOptionArray());
$select->setLabel(__('Content'));
@@ -137,6 +143,7 @@ public function getContentResponse()
$renderer = $this->_fieldElement;
+ /** @noinspection PhpPossiblePolymorphicInvocationInspection */
$this->getResponse()
->setHttpResponseCode(200)
->setHeader('Content-Type', 'application/json', true)
@@ -147,13 +154,18 @@ public function getContentResponse()
])
);
- } catch (\Exception $e) {
+ } catch (Exception $e) {
$this->clerk_logger->error('Widget getContentResponse ERROR', ['error' => $e->getMessage()]);
}
}
+ /**
+ * Get parameters for response
+ *
+ * @return void
+ */
public function getParametersResponse()
{
try {
@@ -166,7 +178,6 @@ public function getParametersResponse()
$html = '';
if (!!array_intersect(['products', 'category'], $parameters)) {
- /** @var Form $form */
$form = $this->formFactory->create();
$form->setFieldsetRenderer($this->_fieldSet);
$form->setUseContainer(false);
@@ -229,6 +240,7 @@ public function getParametersResponse()
$html .= $form->toHtml();
}
+ /** @noinspection PhpPossiblePolymorphicInvocationInspection */
$this->getResponse()
->setHttpResponseCode(200)
->setHeader('Content-Type', 'application/json', true)
@@ -239,17 +251,23 @@ public function getParametersResponse()
])
);
- } catch (\Exception $e) {
+ } catch (Exception $e) {
$this->clerk_logger->error('Widget getParametersResponse ERROR', ['error' => $e->getMessage()]);
}
}
+ /**
+ * Get invalid response
+ *
+ * @return void
+ */
public function getInvalidResponse()
{
try {
+ /** @noinspection PhpPossiblePolymorphicInvocationInspection */
$this->getResponse()
->setHttpResponseCode(422)
->setHeader('Content-Type', 'application/json', true)
@@ -260,7 +278,7 @@ public function getInvalidResponse()
])
);
- } catch (\Exception $e) {
+ } catch (Exception $e) {
$this->clerk_logger->error('Widget getInvalidResponse ERROR', ['error' => $e->getMessage()]);
diff --git a/Controller/Cart/Added.php b/Controller/Cart/Added.php
index 9421f34..e94ebf3 100644
--- a/Controller/Cart/Added.php
+++ b/Controller/Cart/Added.php
@@ -2,16 +2,17 @@
namespace Clerk\Clerk\Controller\Cart;
+use Clerk\Clerk\Controller\Logger\ClerkLogger;
+use Exception;
use Magento\Catalog\Controller\Product;
use Magento\Framework\App\Action\Context;
-use Magento\Framework\App\ResponseInterface;
+use Magento\Framework\View\Result\Page;
use Magento\Framework\View\Result\PageFactory;
-use Clerk\Clerk\Controller\Logger\ClerkLogger;
class Added extends Product
{
/**
- * @var
+ * @var ClerkLogger
*/
protected $clerk_logger;
@@ -25,43 +26,36 @@ class Added extends Product
*
* @param Context $context
* @param PageFactory $resultPageFactory
+ * @param ClerkLogger $clerk_logger
*/
public function __construct(
Context $context,
PageFactory $resultPageFactory,
ClerkLogger $clerk_logger
- )
- {
+ ) {
$this->resultPageFactory = $resultPageFactory;
$this->clerk_logger = $clerk_logger;
parent::__construct($context);
}
-
/**
* Dispatch request
*
- * @return \Magento\Framework\Controller\ResultInterface|ResponseInterface
- * @throws \Magento\Framework\Exception\NotFoundException
+ * @return Page|void
*/
public function execute()
{
try {
$product = $this->_initProduct();
-
if (!$product) {
//Redirect to frontpage
$this->_redirect('/');
- return;
}
-
return $this->resultPageFactory->create();
- } catch (\Exception $e) {
-
+ } catch (Exception $e) {
$this->clerk_logger->error('Cart execute ERROR', ['error' => $e->getMessage()]);
-
}
}
}
diff --git a/Controller/Category/Index.php b/Controller/Category/Index.php
index 0c82259..a9d9ecc 100644
--- a/Controller/Category/Index.php
+++ b/Controller/Category/Index.php
@@ -2,21 +2,22 @@
namespace Clerk\Clerk\Controller\Category;
-use Clerk\Clerk\Model\Api;
use Clerk\Clerk\Controller\AbstractAction;
+use Clerk\Clerk\Controller\Logger\ClerkLogger;
+use Clerk\Clerk\Model\Api;
+use Exception;
+use Magento\Catalog\Model\CategoryFactory;
+use Magento\Catalog\Model\ResourceModel\Category\CollectionFactory;
use Magento\Cms\Helper\Page;
+use Magento\Cms\Model\ResourceModel\Page\CollectionFactory as PageCollectionFactory;
use Magento\Framework\App\Action\Context;
-use Magento\Store\Model\StoreManagerInterface;
use Magento\Framework\App\Config\ScopeConfigInterface;
-use Magento\Catalog\Model\ResourceModel\Category\CollectionFactory;
-use Magento\Cms\Model\ResourceModel\Page\CollectionFactory as PageCollectionFactory;
+use Magento\Framework\App\ProductMetadataInterface;
+use Magento\Framework\Exception\LocalizedException;
use Magento\Framework\Module\ModuleList;
-use Psr\Log\LoggerInterface;
-use Clerk\Clerk\Controller\Logger\ClerkLogger;
use Magento\Framework\Webapi\Rest\Request as RequestApi;
-use Magento\Framework\App\ProductMetadataInterface;
-use Magento\Catalog\Model\CategoryFactory;
-use Magento\Catalog\Api\CategoryRepositoryInterface;
+use Magento\Store\Model\StoreManagerInterface;
+use Psr\Log\LoggerInterface;
class Index extends AbstractAction
{
@@ -73,32 +74,34 @@ class Index extends AbstractAction
*
* @param Context $context
* @param ScopeConfigInterface $scopeConfig
+ * @param StoreManagerInterface $storeManager
* @param CollectionFactory $categoryCollectionFactory
+ * @param CategoryFactory $categoryFactory
* @param LoggerInterface $logger
* @param PageCollectionFactory $pageCollectionFactory
* @param Page $pageHelper
- * @param StoreManagerInterface $storeManager
- * @param CategoryRepositoryInterface $categoryRepository
- * @param CategoryFactory $categoryFactory
+ * @param ClerkLogger $clerk_logger
+ * @param ModuleList $moduleList
* @param ProductMetadataInterface $product_metadata
* @param RequestApi $request_api
* @param Api $api
*/
public function __construct(
- Context $context,
- ScopeConfigInterface $scopeConfig,
- StoreManagerInterface $storeManager,
- CollectionFactory $categoryCollectionFactory,
- CategoryFactory $categoryFactory,
- LoggerInterface $logger,
- PageCollectionFactory $pageCollectionFactory,
- Page $pageHelper,
- ClerkLogger $clerk_logger,
- ModuleList $moduleList,
+ Context $context,
+ ScopeConfigInterface $scopeConfig,
+ StoreManagerInterface $storeManager,
+ CollectionFactory $categoryCollectionFactory,
+ CategoryFactory $categoryFactory,
+ LoggerInterface $logger,
+ PageCollectionFactory $pageCollectionFactory,
+ Page $pageHelper,
+ ClerkLogger $clerk_logger,
+ ModuleList $moduleList,
ProductMetadataInterface $product_metadata,
- RequestApi $request_api,
- Api $api
- ) {
+ RequestApi $request_api,
+ Api $api
+ )
+ {
$this->moduleList = $moduleList;
$this->collectionFactory = $categoryCollectionFactory;
$this->pageCollectionFactory = $pageCollectionFactory;
@@ -131,7 +134,7 @@ public function __construct(
protected function addFieldHandlers()
{
try {
- //Add parent fieldhandler
+ //Add parent field handler
$this->addFieldHandler('parent', function ($item) {
return $item->getParentId();
});
@@ -139,16 +142,15 @@ protected function addFieldHandlers()
$this->addFieldHandler('parent_name', function ($item) {
$parentId = $item->getParentId();
$parent = $this->categoryFactory->create()->load($parentId);
- $parent_name = $parent->getName();
- return $parent_name;
+ return $parent->getName();
});
- //Add url fieldhandler
+ //Add url field handler
$this->addFieldHandler('url', function ($item) {
return $item->getUrl();
});
- //Add subcategories fieldhandler
+ //Add subcategories field handler
$this->addFieldHandler('subcategories', function ($item) {
$children = $item->getAllChildren(true);
//Remove own ID from subcategories array
@@ -163,7 +165,7 @@ protected function addFieldHandlers()
return $item->getShortName();
});
- } catch (\Exception $e) {
+ } catch (Exception $e) {
$this->clerk_logger->error('Category addFieldHandlers ERROR', ['error' => $e->getMessage()]);
@@ -207,6 +209,7 @@ public function execute()
}
}
+ /** @noinspection PhpPossiblePolymorphicInvocationInspection */
$this->getResponse()
->setHttpResponseCode(200)
->setHeader('Content-Type', 'application/json', true);
@@ -218,7 +221,8 @@ public function execute()
$this->getResponse()->setBody(json_encode($response));
$this->clerk_logger->log('Fetched page ' . $this->page . ' with ' . count($response) . ' Categories', ['response' => $response]);
}
- } catch (\Exception $e) {
+ } catch (Exception $e) {
+ /** @noinspection PhpPossiblePolymorphicInvocationInspection */
$this->getResponse()
->setHttpResponseCode(500)
->setHeader('Content-Type', 'application/json', true)
@@ -240,7 +244,7 @@ public function execute()
* Prepare collection
*
* @return mixed
- * @throws \Magento\Framework\Exception\LocalizedException
+ * @throws LocalizedException
*/
protected function prepareCollection()
{
@@ -262,7 +266,7 @@ protected function prepareCollection()
return $collection;
- } catch (\Exception $e) {
+ } catch (Exception $e) {
$this->clerk_logger->error('Category prepareCollection ERROR', ['error' => $e->getMessage()]);
diff --git a/Controller/Checkout/Cart/Add.php b/Controller/Checkout/Cart/Add.php
index 3a62ec4..30dec70 100644
--- a/Controller/Checkout/Cart/Add.php
+++ b/Controller/Checkout/Cart/Add.php
@@ -4,9 +4,6 @@
use Clerk\Clerk\Model\Config;
use Magento\Checkout\Controller\Cart\Add as BaseAdd;
-use Clerk\Clerk\Controller\Logger\ClerkLogger;
-use Magento\Checkout\Model\Session;
-use Magento\Framework\App\Action\Context;
use Magento\Store\Model\ScopeInterface;
class Add extends BaseAdd
@@ -14,8 +11,7 @@ class Add extends BaseAdd
/**
* Get resolved back url
*
- * @param null $defaultUrl
- *
+ * @param string|void $defaultUrl
* @return mixed|null|string
*/
protected function getBackUrl($defaultUrl = null)
diff --git a/Controller/Customer/Index.php b/Controller/Customer/Index.php
index 8aa6ad8..ad41af9 100644
--- a/Controller/Customer/Index.php
+++ b/Controller/Customer/Index.php
@@ -2,22 +2,23 @@
namespace Clerk\Clerk\Controller\Customer;
-use Clerk\Clerk\Model\Api;
use Clerk\Clerk\Controller\AbstractAction;
use Clerk\Clerk\Controller\Logger\ClerkLogger;
+use Clerk\Clerk\Model\Api;
use Clerk\Clerk\Model\Config;
+use Exception;
+use Magento\Customer\Api\CustomerMetadataInterface;
+use Magento\Customer\Api\GroupRepositoryInterface;
+use Magento\Customer\Model\ResourceModel\Customer\CollectionFactory;
use Magento\Framework\App\Action\Context;
-use Magento\Store\Model\StoreManagerInterface;
use Magento\Framework\App\Config\ScopeConfigInterface;
-use Magento\Customer\Model\ResourceModel\Customer\CollectionFactory;
+use Magento\Framework\App\ProductMetadataInterface;
+use Magento\Framework\Module\ModuleList;
+use Magento\Framework\Webapi\Rest\Request as RequestApi;
use Magento\Newsletter\Model\ResourceModel\Subscriber\CollectionFactory as SubscriberCollectionFactory;
use Magento\Newsletter\Model\SubscriberFactory as SubscriberFactory;
-use Magento\Framework\Module\ModuleList;
+use Magento\Store\Model\StoreManagerInterface;
use Psr\Log\LoggerInterface;
-use Magento\Customer\Api\CustomerMetadataInterface;
-use Magento\Framework\Webapi\Rest\Request as RequestApi;
-use Magento\Framework\App\ProductMetadataInterface;
-use Magento\Customer\Api\GroupRepositoryInterface;
class Index extends AbstractAction
{
@@ -66,28 +67,37 @@ class Index extends AbstractAction
* Customer controller constructor.
*
* @param Context $context
+ * @param StoreManagerInterface $storeManager
* @param ScopeConfigInterface $scopeConfig
* @param CollectionFactory $customerCollectionFactory
+ * @param LoggerInterface $logger
+ * @param ModuleList $moduleList
+ * @param ClerkLogger $clerk_logger
+ * @param CustomerMetadataInterface $customerMetadata
* @param ProductMetadataInterface $product_metadata
* @param RequestApi $request_api
+ * @param SubscriberFactory $subscriberFactory
+ * @param SubscriberCollectionFactory $subscriberCollectionFactory
* @param Api $api
+ * @param GroupRepositoryInterface $groupRepository
*/
public function __construct(
- Context $context,
- StoreManagerInterface $storeManager,
- ScopeConfigInterface $scopeConfig,
- CollectionFactory $customerCollectionFactory,
- LoggerInterface $logger,
- ModuleList $moduleList,
- ClerkLogger $clerk_logger,
- CustomerMetadataInterface $customerMetadata,
- ProductMetadataInterface $product_metadata,
- RequestApi $request_api,
- SubscriberFactory $subscriberFactory,
+ Context $context,
+ StoreManagerInterface $storeManager,
+ ScopeConfigInterface $scopeConfig,
+ CollectionFactory $customerCollectionFactory,
+ LoggerInterface $logger,
+ ModuleList $moduleList,
+ ClerkLogger $clerk_logger,
+ CustomerMetadataInterface $customerMetadata,
+ ProductMetadataInterface $product_metadata,
+ RequestApi $request_api,
+ SubscriberFactory $subscriberFactory,
SubscriberCollectionFactory $subscriberCollectionFactory,
- Api $api,
- GroupRepositoryInterface $groupRepository
- ) {
+ Api $api,
+ GroupRepositoryInterface $groupRepository
+ )
+ {
$this->collectionFactory = $customerCollectionFactory;
$this->clerk_logger = $clerk_logger;
$this->_customerMetadata = $customerMetadata;
@@ -108,6 +118,11 @@ public function __construct(
);
}
+ /**
+ * Execute page function
+ *
+ * @return void
+ */
public function execute()
{
try {
@@ -115,6 +130,7 @@ public function execute()
if ($this->scopeConfig->getValue(Config::XML_PATH_CUSTOMER_SYNCHRONIZATION_ENABLED, $this->scope, $this->scopeid)) {
$Customers = [];
+ /** @noinspection PhpPossiblePolymorphicInvocationInspection */
$this->getResponse()
->setHttpResponseCode(200)
->setHeader('Content-Type', 'application/json', true);
@@ -135,7 +151,7 @@ public function execute()
foreach ($response->getData() as $customer) {
- $_customer = array();
+ $_customer = [];
$_customer['id'] = $customer['entity_id'];
$_customer['name'] = $customer['firstname'] . " " . (!is_null($customer['middlename']) ? $customer['middlename'] . " " : "") . $customer['lastname'];
$_customer['email'] = $customer['email'];
@@ -161,7 +177,7 @@ public function execute()
if ($this->scopeConfig->getValue(Config::XML_PATH_SUBSCRIBER_SYNCHRONIZATION_ENABLED, $this->scope, $this->scopeid)) {
$sub_state = $subscriberInstance->loadByEmail($customer['email']);
if ($sub_state->getId()) {
- $_customer['subscribed'] = (bool) ($sub_state->getSubscriberStatus() == 1);
+ $_customer['subscribed'] = (bool)($sub_state->getSubscriberStatus() == 1);
} else {
$_customer['subscribed'] = false;
}
@@ -178,10 +194,10 @@ public function execute()
foreach ($subscribersOnlyResponse->getData() as $subscriber) {
if (isset($subscriber['subscriber_id'])) {
$sub_state = $subscriberInstance->loadByEmail($subscriber['subscriber_email']);
- $_sub = array();
+ $_sub = [];
$_sub['id'] = 'SUB' . $subscriber['subscriber_id'];
$_sub['email'] = $subscriber['subscriber_email'];
- $_sub['subscribed'] = (bool) ($subscriber['subscriber_status'] == 1);
+ $_sub['subscribed'] = (bool)($subscriber['subscriber_status'] == 1);
$_sub['name'] = "";
$_sub['firstname'] = "";
$_sub['unsub_url'] = $sub_state->getUnsubscriptionLink();
@@ -197,6 +213,7 @@ public function execute()
}
} else {
+ /** @noinspection PhpPossiblePolymorphicInvocationInspection */
$this->getResponse()
->setHttpResponseCode(200)
->setHeader('Content-Type', 'application/json', true);
@@ -205,7 +222,7 @@ public function execute()
}
- } catch (\Exception $e) {
+ } catch (Exception $e) {
$this->clerk_logger->error('Customer execute ERROR', ['error' => $e->getMessage()]);
@@ -222,6 +239,11 @@ public function getCustomerCollection($page, $limit, $storeid)
return $customerCollection;
}
+ public function getCustomerGender($GenderCode)
+ {
+ return $this->_customerMetadata->getAttributeMetadata('gender')->getOptions()[$GenderCode]->getLabel();
+ }
+
public function getSubscriberCollection($page, $limit, $storeid)
{
$subscriberCollection = $this->_subscriberCollectionFactory->create();
@@ -231,9 +253,4 @@ public function getSubscriberCollection($page, $limit, $storeid)
$subscriberCollection->setCurPage($page);
return $subscriberCollection;
}
-
- public function getCustomerGender($GenderCode)
- {
- return $this->_customerMetadata->getAttributeMetadata('gender')->getOptions()[$GenderCode]->getLabel();
- }
}
diff --git a/Controller/Getconfig/Index.php b/Controller/Getconfig/Index.php
index c89f089..15ecd9d 100644
--- a/Controller/Getconfig/Index.php
+++ b/Controller/Getconfig/Index.php
@@ -2,18 +2,18 @@
namespace Clerk\Clerk\Controller\Getconfig;
-use Clerk\Clerk\Model\Api;
use Clerk\Clerk\Controller\AbstractAction;
-use Magento\Framework\App\Action\Context;
-use Magento\Framework\App\Config\ScopeConfigInterface;
-use Magento\Store\Model\StoreManagerInterface;
-use Magento\Framework\Module\ModuleList;
-use Psr\Log\LoggerInterface;
use Clerk\Clerk\Controller\Logger\ClerkLogger;
-use Magento\Store\Model\ScopeInterface;
+use Clerk\Clerk\Model\Api;
use Clerk\Clerk\Model\Config;
+use Exception;
+use Magento\Framework\App\Action\Context;
+use Magento\Framework\App\Config\ScopeConfigInterface;
use Magento\Framework\App\ProductMetadataInterface;
+use Magento\Framework\Module\ModuleList;
use Magento\Framework\Webapi\Rest\Request as RequestApi;
+use Magento\Store\Model\StoreManagerInterface;
+use Psr\Log\LoggerInterface;
class Index extends AbstractAction
{
@@ -39,16 +39,17 @@ class Index extends AbstractAction
* @param Api $api
*/
public function __construct(
- Context $context,
- ScopeConfigInterface $scopeConfig,
- LoggerInterface $logger,
- ModuleList $moduleList,
- StoreManagerInterface $storeManager,
- ClerkLogger $clerk_logger,
+ Context $context,
+ ScopeConfigInterface $scopeConfig,
+ LoggerInterface $logger,
+ ModuleList $moduleList,
+ StoreManagerInterface $storeManager,
+ ClerkLogger $clerk_logger,
ProductMetadataInterface $product_metadata,
- RequestApi $request_api,
- Api $api
- ) {
+ RequestApi $request_api,
+ Api $api
+ )
+ {
$this->moduleList = $moduleList;
$this->clerk_logger = $clerk_logger;
parent::__construct(
@@ -74,7 +75,8 @@ public function execute()
$scope = $this->getRequest()->getParam('scope');
$scopeID = 1;
-
+ $storeID = null;
+ $websiteID = null;
if (null !== $this->getRequest()->getParam('scope_id')) {
$scopeID = $this->getRequest()->getParam('scope_id');
}
@@ -90,6 +92,7 @@ public function execute()
$storeID = $scopeID;
}
+ /** @noinspection PhpPossiblePolymorphicInvocationInspection */
$this->getResponse()
->setHttpResponseCode(200)
->setHeader('Content-Type', 'application/json', true);
@@ -174,7 +177,7 @@ public function execute()
} else {
$this->getResponse()->setBody(json_encode($response));
}
- } catch (\Exception $e) {
+ } catch (Exception $e) {
$this->clerk_logger->error('Getconfig execute ERROR', ['error' => $e->getMessage()]);
diff --git a/Controller/Index.php b/Controller/Index.php
index b5aba42..9e1b5e5 100644
--- a/Controller/Index.php
+++ b/Controller/Index.php
@@ -4,17 +4,20 @@
use Magento\Framework\App\Action\Action;
use Magento\Framework\App\ResponseInterface;
+use Magento\Framework\Controller\ResultInterface;
+use Magento\Framework\Exception\NotFoundException;
class Index extends Action
{
/**
* Dispatch request
*
- * @return \Magento\Framework\Controller\ResultInterface|ResponseInterface
- * @throws \Magento\Framework\Exception\NotFoundException
+ * @return ResultInterface|ResponseInterface
+ * @throws NotFoundException
*/
public function execute()
{
+ /** @noinspection PhpPossiblePolymorphicInvocationInspection */
$this->getResponse()->setHeader('Content-Type', 'application/json', true);
$this->getResponse()->setBody(json_encode(['products' => [], 'categories' => [], 'sales' => [], 'pages' => []], JSON_PRETTY_PRINT));
}
diff --git a/Controller/Logger/ClerkLogger.php b/Controller/Logger/ClerkLogger.php
index 55954e6..6650425 100644
--- a/Controller/Logger/ClerkLogger.php
+++ b/Controller/Logger/ClerkLogger.php
@@ -86,8 +86,7 @@ function __construct(
ConfigInterface $configWriter,
ModuleList $moduleList,
ProductMetadataInterface $product_metadata
- )
- {
+ ) {
$this->configWriter = $configWriter;
$this->directory = $dir;
@@ -328,7 +327,7 @@ public function logToFile($message, $metadata)
fopen($log_path, "a+");
file_put_contents($log_path, $log_message, FILE_APPEND);
- } catch (FileSystemException) {
+ } catch (FileSystemException $ex) {
// Drop error if file system exception is found
}
}
@@ -372,6 +371,5 @@ public function warn($message, $metadata)
} elseif ($this->loggingMethod == 'file') {
$this->logToFile($message, $metadata);
}
-
}
}
diff --git a/Controller/Order/Index.php b/Controller/Order/Index.php
index cabbe61..0136b07 100644
--- a/Controller/Order/Index.php
+++ b/Controller/Order/Index.php
@@ -2,20 +2,20 @@
namespace Clerk\Clerk\Controller\Order;
-use Clerk\Clerk\Model\Api;
use Clerk\Clerk\Controller\AbstractAction;
+use Clerk\Clerk\Controller\Logger\ClerkLogger;
+use Clerk\Clerk\Model\Api;
use Clerk\Clerk\Model\Config;
+use Exception;
use Magento\Framework\App\Action\Context;
-use Magento\Store\Model\StoreManagerInterface;
use Magento\Framework\App\Config\ScopeConfigInterface;
+use Magento\Framework\App\ProductMetadataInterface;
use Magento\Framework\App\RequestInterface;
use Magento\Framework\Module\ModuleList;
+use Magento\Framework\Webapi\Rest\Request as RequestApi;
use Magento\Sales\Model\ResourceModel\Order\CollectionFactory;
-use Magento\Store\Model\ScopeInterface;
+use Magento\Store\Model\StoreManagerInterface;
use Psr\Log\LoggerInterface;
-use Clerk\Clerk\Controller\Logger\ClerkLogger;
-use Magento\Framework\App\ProductMetadataInterface;
-use Magento\Framework\Webapi\Rest\Request as RequestApi;
class Index extends AbstractAction
{
@@ -52,17 +52,18 @@ class Index extends AbstractAction
* @param Api $api
*/
public function __construct(
- Context $context,
- ScopeConfigInterface $scopeConfig,
- CollectionFactory $orderCollectionFactory,
- StoreManagerInterface $storeManager,
- LoggerInterface $logger,
- ModuleList $moduleList,
- ClerkLogger $clerk_logger,
+ Context $context,
+ ScopeConfigInterface $scopeConfig,
+ CollectionFactory $orderCollectionFactory,
+ StoreManagerInterface $storeManager,
+ LoggerInterface $logger,
+ ModuleList $moduleList,
+ ClerkLogger $clerk_logger,
ProductMetadataInterface $product_metadata,
- RequestApi $request_api,
- Api $api
- ) {
+ RequestApi $request_api,
+ Api $api
+ )
+ {
$this->collectionFactory = $orderCollectionFactory;
$this->clerk_logger = $clerk_logger;
$this->moduleList = $moduleList;
@@ -114,14 +115,14 @@ protected function addFieldHandlers()
foreach ($item->getAllVisibleItems() as $productItem) {
$products[] = [
'id' => $productItem->getProductId(),
- 'quantity' => (int) $productItem->getQtyOrdered(),
- 'price' => (float) $productItem->getPrice(),
+ 'quantity' => (int)$productItem->getQtyOrdered(),
+ 'price' => (float)$productItem->getPrice(),
];
}
return $products;
});
- } catch (\Exception $e) {
+ } catch (Exception $e) {
$this->clerk_logger->error('Order addFieldHandlers ERROR', ['error' => $e->getMessage()]);
@@ -142,6 +143,7 @@ public function execute()
);
if ($disabled) {
+ /** @noinspection PhpPossiblePolymorphicInvocationInspection */
$this->getResponse()
->setHttpResponseCode(200)
->setHeader('Content-Type', 'application/json', true)
@@ -154,7 +156,7 @@ public function execute()
parent::execute();
- } catch (\Exception $e) {
+ } catch (Exception $e) {
$this->clerk_logger->error('Order execute ERROR', ['error' => $e->getMessage()]);
@@ -172,7 +174,7 @@ protected function getArguments(RequestInterface $request)
//Use increment id instead of entity_id
$this->fields = str_replace('entity_id', 'increment_id', $this->fields);
- } catch (\Exception $e) {
+ } catch (Exception $e) {
$this->clerk_logger->error('Order getArguments ERROR', ['error' => $e->getMessage()]);
diff --git a/Controller/Page/Index.php b/Controller/Page/Index.php
index b4c1df7..a1ca119 100644
--- a/Controller/Page/Index.php
+++ b/Controller/Page/Index.php
@@ -2,24 +2,26 @@
namespace Clerk\Clerk\Controller\Page;
-use Clerk\Clerk\Model\Api;
use Clerk\Clerk\Controller\AbstractAction;
+use Clerk\Clerk\Controller\Logger\ClerkLogger;
+use Clerk\Clerk\Model\Api;
use Clerk\Clerk\Model\Config;
+use Exception;
+use Magento\Cms\Api\PageRepositoryInterface;
+use Magento\Cms\Helper\Page as PageHelper;
+use Magento\Cms\Model\ResourceModel\Page\CollectionFactory as PageFactory;
+use Magento\Framework\Api\SearchCriteriaBuilder;
+use Magento\Framework\Api\SearchCriteriaBuilderFactory;
use Magento\Framework\App\Action\Context;
-use Magento\Store\Model\StoreManagerInterface;
use Magento\Framework\App\Config\ScopeConfigInterface;
+use Magento\Framework\App\ProductMetadataInterface;
+use Magento\Framework\App\ResponseInterface;
+use Magento\Framework\Controller\ResultInterface;
+use Magento\Framework\Exception\FileSystemException;
use Magento\Framework\Module\ModuleList;
-use Magento\Framework\App\RequestInterface;
-use Magento\Framework\Api\SearchCriteriaBuilder;
-use Magento\Framework\Api\SearchCriteriaBuilderFactory;
-use Magento\Cms\Api\PageRepositoryInterface;
-use Psr\Log\LoggerInterface;
-use Magento\Store\Model\ScopeInterface;
-use Clerk\Clerk\Controller\Logger\ClerkLogger;
use Magento\Framework\Webapi\Rest\Request as RequestApi;
-use Magento\Cms\Helper\Page as PageHelper;
-use Magento\Framework\App\ProductMetadataInterface;
-use Magento\Cms\Model\ResourceModel\Page\CollectionFactory as PageFactory;
+use Magento\Store\Model\StoreManagerInterface;
+use Psr\Log\LoggerInterface;
class Index extends AbstractAction
{
@@ -84,21 +86,22 @@ class Index extends AbstractAction
* @param Api $api
*/
public function __construct(
- Context $context,
- ScopeConfigInterface $scopeConfig,
- PageRepositoryInterface $PageRepositoryInterface,
- SearchCriteriaBuilder $SearchCriteriaBuilder,
- StoreManagerInterface $storeManager,
+ Context $context,
+ ScopeConfigInterface $scopeConfig,
+ PageRepositoryInterface $PageRepositoryInterface,
+ SearchCriteriaBuilder $SearchCriteriaBuilder,
+ StoreManagerInterface $storeManager,
SearchCriteriaBuilderFactory $searchCriteriaBuilderFactory,
- LoggerInterface $logger,
- ClerkLogger $clerk_logger,
- ModuleList $moduleList,
- PageHelper $pageHelper,
- ProductMetadataInterface $product_metadata,
- PageFactory $pageFactory,
- RequestApi $request_api,
- Api $api
- ) {
+ LoggerInterface $logger,
+ ClerkLogger $clerk_logger,
+ ModuleList $moduleList,
+ PageHelper $pageHelper,
+ ProductMetadataInterface $product_metadata,
+ PageFactory $pageFactory,
+ RequestApi $request_api,
+ Api $api
+ )
+ {
$this->_searchCriteriaBuilderFactory = $searchCriteriaBuilderFactory;
$this->_PageRepositoryInterface = $PageRepositoryInterface;
$this->_SearchCriteriaBuilder = $SearchCriteriaBuilder;
@@ -122,8 +125,8 @@ public function __construct(
}
/**
- * @return \Magento\Framework\App\ResponseInterface|\Magento\Framework\Controller\ResultInterface|void
- * @throws \Magento\Framework\Exception\FileSystemException
+ * @return ResponseInterface|ResultInterface|void
+ * @throws FileSystemException
*/
public function execute()
{
@@ -138,6 +141,7 @@ public function execute()
if ($Include_pages) {
+ /** @noinspection PhpPossiblePolymorphicInvocationInspection */
$this->getResponse()
->setHttpResponseCode(200)
->setHeader('Content-Type', 'application/json', true);
@@ -180,7 +184,7 @@ public function execute()
$pages[] = $page;
- } catch (\Exception $e) {
+ } catch (Exception $e) {
continue;
@@ -226,7 +230,7 @@ public function execute()
$pages[] = $page;
- } catch (\Exception $e) {
+ } catch (Exception $e) {
continue;
@@ -238,13 +242,25 @@ public function execute()
$this->getResponse()->setBody(json_encode($pages));
- } catch (\Exception $e) {
+ } catch (Exception $e) {
$this->clerk_logger->error('Product execute ERROR', ['error' => $e->getMessage()]);
}
}
+ public function getPageCollection($page, $limit, $storeid)
+ {
+
+ $store = $this->storeManager->getStore($storeid);
+ $collection = $this->_pageFactory->create();
+ $collection->addFilter('is_active', 1);
+ $collection->addFilter('store_id', $store->getId());
+ $collection->addStoreFilter($store);
+ $collection->setPageSize($limit);
+ $collection->setCurPage($page);
+ return $collection;
+ }
public function ValidatePage($Page)
{
@@ -261,17 +277,4 @@ public function ValidatePage($Page)
return true;
}
-
- public function getPageCollection($page, $limit, $storeid)
- {
-
- $store = $this->storeManager->getStore($storeid);
- $collection = $this->_pageFactory->create();
- $collection->addFilter('is_active', 1);
- $collection->addFilter('store_id', $store->getId());
- $collection->addStoreFilter($store);
- $collection->setPageSize($limit);
- $collection->setCurPage($page);
- return $collection;
- }
}
diff --git a/Controller/Plugin/Index.php b/Controller/Plugin/Index.php
index 7d7eff8..0d7358e 100644
--- a/Controller/Plugin/Index.php
+++ b/Controller/Plugin/Index.php
@@ -2,16 +2,17 @@
namespace Clerk\Clerk\Controller\Plugin;
-use Clerk\Clerk\Model\Api;
use Clerk\Clerk\Controller\AbstractAction;
+use Clerk\Clerk\Controller\Logger\ClerkLogger;
+use Clerk\Clerk\Model\Api;
+use Exception;
use Magento\Framework\App\Action\Context;
use Magento\Framework\App\Config\ScopeConfigInterface;
+use Magento\Framework\App\ProductMetadataInterface;
use Magento\Framework\Module\ModuleList;
+use Magento\Framework\Webapi\Rest\Request as RequestApi;
use Magento\Store\Model\StoreManagerInterface;
-use Clerk\Clerk\Controller\Logger\ClerkLogger;
use Psr\Log\LoggerInterface;
-use Magento\Framework\Webapi\Rest\Request as RequestApi;
-use Magento\Framework\App\ProductMetadataInterface;
class Index extends AbstractAction
{
@@ -23,23 +24,27 @@ class Index extends AbstractAction
* Version controller constructor.
*
* @param Context $context
+ * @param StoreManagerInterface $storeManager
* @param ScopeConfigInterface $scopeConfig
* @param LoggerInterface $logger
* @param ModuleList $moduleList
+ * @param ClerkLogger $clerk_logger
* @param ProductMetadataInterface $product_metadata
* @param RequestApi $request_api
+ * @param Api $api
*/
public function __construct(
- Context $context,
- StoreManagerInterface $storeManager,
- ScopeConfigInterface $scopeConfig,
- LoggerInterface $logger,
- ModuleList $moduleList,
- ClerkLogger $clerk_logger,
+ Context $context,
+ StoreManagerInterface $storeManager,
+ ScopeConfigInterface $scopeConfig,
+ LoggerInterface $logger,
+ ModuleList $moduleList,
+ ClerkLogger $clerk_logger,
ProductMetadataInterface $product_metadata,
- RequestApi $request_api,
- Api $api
- ) {
+ RequestApi $request_api,
+ Api $api
+ )
+ {
$this->moduleList = $moduleList;
$this->clerk_logger = $clerk_logger;
parent::__construct(
@@ -61,6 +66,7 @@ public function __construct(
public function execute()
{
try {
+ /** @noinspection PhpPossiblePolymorphicInvocationInspection */
$this->getResponse()
->setHttpResponseCode(200)
->setHeader('Content-Type', 'application/json', true);
@@ -72,7 +78,7 @@ public function execute()
} else {
$this->getResponse()->setBody(json_encode($response));
}
- } catch (\Exception $e) {
+ } catch (Exception $e) {
$this->clerk_logger->error('Plugin execute ERROR', ['error' => $e->getMessage()]);
diff --git a/Controller/Powerstep/Popup.php b/Controller/Powerstep/Popup.php
index ae3a35a..756a652 100644
--- a/Controller/Powerstep/Popup.php
+++ b/Controller/Powerstep/Popup.php
@@ -2,13 +2,12 @@
namespace Clerk\Clerk\Controller\Powerstep;
-use Clerk\Clerk\Block\PowerstepPopup;
+use Clerk\Clerk\Controller\Logger\ClerkLogger;
+use Exception;
use Magento\Checkout\Model\Session;
use Magento\Framework\App\Action\Action;
use Magento\Framework\App\Action\Context;
-use Magento\Framework\App\ResponseInterface;
use Magento\Framework\Controller\ResultFactory;
-use Clerk\Clerk\Controller\Logger\ClerkLogger;
class Popup extends Action
{
@@ -22,10 +21,10 @@ class Popup extends Action
protected $checkoutSession;
public function __construct(
- Context $context,
- Session $checkoutSession,
+ Context $context,
+ Session $checkoutSession,
ClerkLogger $clerk_logger
- )
+ )
{
parent::__construct($context);
$this->checkoutSession = $checkoutSession;
@@ -41,7 +40,6 @@ public function execute()
{
try {
- /** @var Page $response */
$response = $this->resultFactory->create(ResultFactory::TYPE_PAGE);
$layout = $response->addHandle('clerk_clerk_powerstep_popup')->getLayout();
@@ -49,7 +47,7 @@ public function execute()
$this->getResponse()->setBody($response);
return;
- } catch (\Exception $e) {
+ } catch (Exception $e) {
$this->clerk_logger->error('Powerstep execute ERROR', ['error' => $e->getMessage()]);
diff --git a/Controller/Product/Index.php b/Controller/Product/Index.php
index cf6cfdf..f07b615 100644
--- a/Controller/Product/Index.php
+++ b/Controller/Product/Index.php
@@ -2,23 +2,25 @@
namespace Clerk\Clerk\Controller\Product;
-use Clerk\Clerk\Model\Api;
-use Clerk\Clerk\Model\Adapter\Product as ProductAdapter;
use Clerk\Clerk\Controller\AbstractAction;
+use Clerk\Clerk\Controller\Logger\ClerkLogger;
use Clerk\Clerk\Model\Adapter\Product;
-use Magento\Store\Model\StoreManagerInterface;
-use Clerk\Clerk\Model\Config;
-use Magento\Catalog\Model\Product\Visibility;
-use Magento\Framework\App\Action\Action;
+use Clerk\Clerk\Model\Adapter\Product as ProductAdapter;
+use Clerk\Clerk\Model\Api;
+use Exception;
+use Magento\Catalog\Helper\Data;
use Magento\Framework\App\Action\Context;
use Magento\Framework\App\Config\ScopeConfigInterface;
+use Magento\Framework\App\ProductMetadataInterface;
use Magento\Framework\App\RequestInterface;
+use Magento\Framework\App\ResponseInterface;
+use Magento\Framework\Controller\ResultInterface;
+use Magento\Framework\Data\Collection;
+use Magento\Framework\Exception\FileSystemException;
use Magento\Framework\Module\ModuleList;
-use Magento\Catalog\Helper\Data;
-use Psr\Log\LoggerInterface;
-use Clerk\Clerk\Controller\Logger\ClerkLogger;
use Magento\Framework\Webapi\Rest\Request as RequestApi;
-use Magento\Framework\App\ProductMetadataInterface;
+use Magento\Store\Model\StoreManagerInterface;
+use Psr\Log\LoggerInterface;
class Index extends AbstractAction
{
@@ -59,18 +61,19 @@ class Index extends AbstractAction
* @param Api $api
*/
public function __construct(
- Context $context,
- ScopeConfigInterface $scopeConfig,
- StoreManagerInterface $storeManager,
- ProductAdapter $productAdapter,
- ClerkLogger $clerk_logger,
- LoggerInterface $logger,
- Data $taxHelper,
- ModuleList $moduleList,
+ Context $context,
+ ScopeConfigInterface $scopeConfig,
+ StoreManagerInterface $storeManager,
+ ProductAdapter $productAdapter,
+ ClerkLogger $clerk_logger,
+ LoggerInterface $logger,
+ Data $taxHelper,
+ ModuleList $moduleList,
ProductMetadataInterface $product_metadata,
- RequestApi $request_api,
- Api $api
- ) {
+ RequestApi $request_api,
+ Api $api
+ )
+ {
$this->taxHelper = $taxHelper;
$this->moduleList = $moduleList;
$this->productAdapter = $productAdapter;
@@ -89,13 +92,14 @@ public function __construct(
}
/**
- * @return \Magento\Framework\App\ResponseInterface|\Magento\Framework\Controller\ResultInterface|void
- * @throws \Magento\Framework\Exception\FileSystemException
+ * @return ResponseInterface|ResultInterface|void
+ * @throws FileSystemException
*/
public function execute()
{
try {
+ /** @noinspection PhpPossiblePolymorphicInvocationInspection */
$this->getResponse()
->setHttpResponseCode(200)
->setHeader('Content-Type', 'application/json', true);
@@ -124,7 +128,7 @@ public function execute()
$this->getResponse()->setBody(json_encode($response));
- } catch (\Exception $e) {
+ } catch (Exception $e) {
$this->clerk_logger->error('Product execute ERROR', ['error' => $e->getMessage()]);
@@ -139,17 +143,17 @@ protected function getArguments(RequestInterface $request)
{
try {
- $this->debug = (bool) $request->getParam('debug', false);
- $this->limit = (int) $request->getParam('limit', 0);
- $this->page = (int) $request->getParam('page', 0);
+ $this->debug = (bool)$request->getParam('debug', false);
+ $this->limit = (int)$request->getParam('limit', 0);
+ $this->page = (int)$request->getParam('page', 0);
$this->orderBy = $request->getParam('orderby', 'entity_id');
$this->scopeid = $request->getParam('scope_id');
$this->scope = $request->getParam('scope');
if ($request->getParam('order') === 'desc') {
- $this->order = \Magento\Framework\Data\Collection::SORT_ORDER_DESC;
+ $this->order = Collection::SORT_ORDER_DESC;
} else {
- $this->order = \Magento\Framework\Data\Collection::SORT_ORDER_ASC;
+ $this->order = Collection::SORT_ORDER_ASC;
}
/**
@@ -160,7 +164,7 @@ protected function getArguments(RequestInterface $request)
$this->fields = array_filter(explode(',', $fields), 'strlen');
}
- } catch (\Exception $e) {
+ } catch (Exception $e) {
$this->clerk_logger->error('Product getArguments ERROR', ['error' => $e->getMessage()]);
diff --git a/Controller/Rotatekey/Index.php b/Controller/Rotatekey/Index.php
index 94e9429..a9c0b84 100644
--- a/Controller/Rotatekey/Index.php
+++ b/Controller/Rotatekey/Index.php
@@ -119,6 +119,7 @@ public function execute()
{
try {
+ /** @noinspection PhpPossiblePolymorphicInvocationInspection */
$post = $this->getRequest()->getcontent();
$scope = $this->getRequest()->getParam('scope');
if ($scope !== 'default') {
@@ -155,6 +156,7 @@ public function execute()
}
+ /** @noinspection PhpPossiblePolymorphicInvocationInspection */
$this->getResponse()
->setHttpResponseCode(200)
->setHeader('Content-Type', 'application/json', true);
diff --git a/Controller/Setconfig/Index.php b/Controller/Setconfig/Index.php
index 5443430..37c9403 100644
--- a/Controller/Setconfig/Index.php
+++ b/Controller/Setconfig/Index.php
@@ -2,20 +2,20 @@
namespace Clerk\Clerk\Controller\Setconfig;
-use Clerk\Clerk\Model\Api;
use Clerk\Clerk\Controller\AbstractAction;
-use Magento\Framework\App\Action\Context;
-use Magento\Framework\App\Config\ScopeConfigInterface;
-use Magento\Store\Model\StoreManagerInterface;
-use Magento\Framework\Module\ModuleList;
-use Psr\Log\LoggerInterface;
use Clerk\Clerk\Controller\Logger\ClerkLogger;
+use Clerk\Clerk\Model\Api;
use Clerk\Clerk\Model\Config;
+use Exception;
+use Magento\Framework\App\Action\Context;
+use Magento\Framework\App\Cache\TypeListInterface as CacheType;
+use Magento\Framework\App\Config\ScopeConfigInterface;
use Magento\Framework\App\Config\Storage\WriterInterface;
-use Magento\Store\Model\ScopeInterface;
use Magento\Framework\App\ProductMetadataInterface;
-use Magento\Framework\App\Cache\TypeListInterface as CacheType;
+use Magento\Framework\Module\ModuleList;
use Magento\Framework\Webapi\Rest\Request as RequestApi;
+use Magento\Store\Model\StoreManagerInterface;
+use Psr\Log\LoggerInterface;
class Index extends AbstractAction
{
@@ -58,27 +58,31 @@ class Index extends AbstractAction
* Version controller constructor.
*
* @param Context $context
- * @param ScopeConfigInterface $scopeConfig
+ * @param ScopeConfigInterface $ScopeConfigInterface
* @param LoggerInterface $logger
* @param ModuleList $moduleList
+ * @param StoreManagerInterface $storeManager
+ * @param ClerkLogger $clerk_logger
+ * @param WriterInterface $configWriter
* @param ProductMetadataInterface $product_metadata
* @param CacheType $cacheType
* @param RequestApi $request_api
* @param Api $api
*/
public function __construct(
- Context $context,
- ScopeConfigInterface $ScopeConfigInterface,
- LoggerInterface $logger,
- ModuleList $moduleList,
- StoreManagerInterface $storeManager,
- ClerkLogger $clerk_logger,
- WriterInterface $configWriter,
+ Context $context,
+ ScopeConfigInterface $ScopeConfigInterface,
+ LoggerInterface $logger,
+ ModuleList $moduleList,
+ StoreManagerInterface $storeManager,
+ ClerkLogger $clerk_logger,
+ WriterInterface $configWriter,
ProductMetadataInterface $product_metadata,
- CacheType $cacheType,
- RequestApi $request_api,
- Api $api
- ) {
+ CacheType $cacheType,
+ RequestApi $request_api,
+ Api $api
+ )
+ {
$this->clerk_logger = $clerk_logger;
$this->config_writer = $configWriter;
$this->_cacheType = $cacheType;
@@ -102,6 +106,7 @@ public function execute()
{
try {
+ /** @noinspection PhpPossiblePolymorphicInvocationInspection */
$post = $this->getRequest()->getcontent();
$scope = $this->getRequest()->getParam('scope');
if ($scope !== 'default') {
@@ -109,13 +114,15 @@ public function execute()
}
$scopeId = intval($this->getRequest()->getParam('scope_id'));
+ $arr_settings = [];
+
if ($post) {
$arr_settings = json_decode($post, true);
$count = 0;
foreach ($arr_settings as $key => $value) {
- // generel
+ // general
if ($key == "LANGUAGE") {
$this->config_writer->save(Config::XML_PATH_LANGUAGE, $value, $scope, $scopeId);
@@ -371,14 +378,15 @@ public function execute()
$count++;
}
- } // foreach
+ }
if ($count != 0) {
$this->_cacheType->cleanType('config');
}
- } // if post
+ }
+ /** @noinspection PhpPossiblePolymorphicInvocationInspection */
$this->getResponse()
->setHttpResponseCode(200)
->setHeader('Content-Type', 'application/json', true);
@@ -400,7 +408,7 @@ public function execute()
}
- } catch (\Exception $e) {
+ } catch (Exception $e) {
$this->clerk_logger->error('Setconfig execute ERROR', ['error' => $e->getMessage()]);
diff --git a/Controller/Subscriber/Index.php b/Controller/Subscriber/Index.php
index 7ba9b9e..4380431 100644
--- a/Controller/Subscriber/Index.php
+++ b/Controller/Subscriber/Index.php
@@ -2,18 +2,19 @@
namespace Clerk\Clerk\Controller\Subscriber;
-use Clerk\Clerk\Model\Api;
use Clerk\Clerk\Controller\AbstractAction;
use Clerk\Clerk\Controller\Logger\ClerkLogger;
+use Clerk\Clerk\Model\Api;
use Clerk\Clerk\Model\Config;
+use Exception;
use Magento\Framework\App\Action\Context;
-use Magento\Store\Model\StoreManagerInterface;
use Magento\Framework\App\Config\ScopeConfigInterface;
-use Magento\Newsletter\Model\ResourceModel\Subscriber\CollectionFactory;
+use Magento\Framework\App\ProductMetadataInterface;
use Magento\Framework\Module\ModuleList;
-use Psr\Log\LoggerInterface;
use Magento\Framework\Webapi\Rest\Request as RequestApi;
-use Magento\Framework\App\ProductMetadataInterface;
+use Magento\Newsletter\Model\ResourceModel\Subscriber\CollectionFactory;
+use Magento\Store\Model\StoreManagerInterface;
+use Psr\Log\LoggerInterface;
class Index extends AbstractAction
{
@@ -33,17 +34,18 @@ class Index extends AbstractAction
* @param Api $api
*/
public function __construct(
- Context $context,
- StoreManagerInterface $storeManager,
- ScopeConfigInterface $scopeConfig,
- CollectionFactory $suscriberCollectionFactory,
- LoggerInterface $logger,
- ModuleList $moduleList,
- ClerkLogger $clerk_logger,
+ Context $context,
+ StoreManagerInterface $storeManager,
+ ScopeConfigInterface $scopeConfig,
+ CollectionFactory $suscriberCollectionFactory,
+ LoggerInterface $logger,
+ ModuleList $moduleList,
+ ClerkLogger $clerk_logger,
ProductMetadataInterface $product_metadata,
- RequestApi $request_api,
- Api $api
- ) {
+ RequestApi $request_api,
+ Api $api
+ )
+ {
$this->collectionFactory = $suscriberCollectionFactory;
$this->clerk_logger = $clerk_logger;
@@ -67,6 +69,7 @@ public function execute()
if ($this->scopeConfig->getValue(Config::XML_PATH_CUSTOMER_SYNCHRONIZATION_ENABLED, $this->scope, $this->scopeid)) {
$Subscribers = [];
+ /** @noinspection PhpPossiblePolymorphicInvocationInspection */
$this->getResponse()
->setHttpResponseCode(200)
->setHeader('Content-Type', 'application/json', true);
@@ -99,6 +102,7 @@ public function execute()
}
} else {
+ /** @noinspection PhpPossiblePolymorphicInvocationInspection */
$this->getResponse()
->setHttpResponseCode(200)
->setHeader('Content-Type', 'application/json', true);
@@ -107,7 +111,7 @@ public function execute()
}
- } catch (\Exception $e) {
+ } catch (Exception $e) {
$this->clerk_logger->error('Customer execute ERROR', ['error' => $e->getMessage()]);
diff --git a/Controller/Version/Index.php b/Controller/Version/Index.php
index 5f3aae3..b6cf301 100644
--- a/Controller/Version/Index.php
+++ b/Controller/Version/Index.php
@@ -2,16 +2,18 @@
namespace Clerk\Clerk\Controller\Version;
-use Clerk\Clerk\Model\Api;
use Clerk\Clerk\Controller\AbstractAction;
+use Clerk\Clerk\Controller\Logger\ClerkLogger;
+use Clerk\Clerk\Model\Api;
+use Exception;
use Magento\Framework\App\Action\Context;
use Magento\Framework\App\Config\ScopeConfigInterface;
-use Magento\Store\Model\StoreManagerInterface;
+use Magento\Framework\App\ProductMetadataInterface;
use Magento\Framework\Module\ModuleList;
-use Psr\Log\LoggerInterface;
-use Clerk\Clerk\Controller\Logger\ClerkLogger;
use Magento\Framework\Webapi\Rest\Request as RequestApi;
-use Magento\Framework\App\ProductMetadataInterface;
+use Magento\Store\Model\ScopeInterface;
+use Magento\Store\Model\StoreManagerInterface;
+use Psr\Log\LoggerInterface;
class Index extends AbstractAction
{
@@ -42,16 +44,17 @@ class Index extends AbstractAction
* @param Api $api
*/
public function __construct(
- Context $context,
- ScopeConfigInterface $scopeConfig,
- LoggerInterface $logger,
- ModuleList $moduleList,
- StoreManagerInterface $storeManager,
- ClerkLogger $clerk_logger,
+ Context $context,
+ ScopeConfigInterface $scopeConfig,
+ LoggerInterface $logger,
+ ModuleList $moduleList,
+ StoreManagerInterface $storeManager,
+ ClerkLogger $clerk_logger,
ProductMetadataInterface $product_metadata,
- RequestApi $request_api,
- Api $api
- ) {
+ RequestApi $request_api,
+ Api $api
+ )
+ {
$this->moduleList = $moduleList;
$this->clerk_logger = $clerk_logger;
$this->_product_metadata = $product_metadata;
@@ -76,6 +79,7 @@ public function execute()
try {
$version = $this->_product_metadata->getVersion();
+ /** @noinspection PhpPossiblePolymorphicInvocationInspection */
$this->getResponse()
->setHttpResponseCode(200)
->setHeader('Content-Type', 'application/json', true);
@@ -84,7 +88,7 @@ public function execute()
$scope = 'default';
$scope_id = '0';
} else {
- $scope = \Magento\Store\Model\ScopeInterface::SCOPE_STORE;
+ $scope = ScopeInterface::SCOPE_STORE;
$scope_id = $this->storeManager->getStore()->getId();
}
@@ -102,7 +106,7 @@ public function execute()
} else {
$this->getResponse()->setBody(json_encode($response));
}
- } catch (\Exception $e) {
+ } catch (Exception $e) {
$this->clerk_logger->error('Version execute ERROR', ['error' => $e->getMessage()]);
diff --git a/Helper/Config.php b/Helper/Config.php
index 3c4e9c9..07a2f9a 100644
--- a/Helper/Config.php
+++ b/Helper/Config.php
@@ -9,9 +9,16 @@ class Config
/**
* @var ScopeConfigInterface
*/
- protected ScopeConfigInterface $scopeConfig;
- private Context $context;
+ protected $scopeConfig;
+ /**
+ * @var Context
+ */
+ private $context;
+ /**
+ * @param ScopeConfigInterface $scopeConfig
+ * @param Context $context
+ */
public function __construct(
ScopeConfigInterface $scopeConfig,
Context $context
@@ -22,7 +29,9 @@ public function __construct(
}
/**
- * @param $key
+ * Get a config flag in frontend context
+ *
+ * @param string $key
* @return bool
*/
public function getFlag($key)
@@ -35,7 +44,9 @@ public function getFlag($key)
}
/**
- * @param $key
+ * Get config templates array in frontend context
+ *
+ * @param string $key
* @return array|string[]
*/
public function getTemplates($key)
@@ -48,7 +59,9 @@ public function getTemplates($key)
}
/**
- * @param $key
+ * Get config value in frontend context
+ *
+ * @param string $key
* @return mixed
*/
public function getValue($key)
@@ -61,6 +74,23 @@ public function getValue($key)
}
/**
+ * Get config value in admin context
+ *
+ * @param string $key
+ * @return mixed
+ */
+ public function getValueAdmin($key)
+ {
+ return $this->scopeConfig->getValue(
+ $key,
+ $this->context->getScopeAdmin(),
+ $this->context->getScopeIdAdmin()
+ );
+ }
+
+ /**
+ * Get base url in frontend context
+ *
* @return string
*/
public function getBaseUrl()
@@ -68,4 +98,4 @@ public function getBaseUrl()
$store = $this->context->getStore();
return $store ? $store->getBaseUrl() : "";
}
-}
\ No newline at end of file
+}
diff --git a/Helper/Context.php b/Helper/Context.php
index 74aa27c..5d16eec 100644
--- a/Helper/Context.php
+++ b/Helper/Context.php
@@ -14,16 +14,21 @@ class Context
/**
* @var StoreManagerInterface
*/
- private StoreManagerInterface $storeManager;
+ private $storeManager;
/**
* @var RequestInterface
*/
- private RequestInterface $request;
+ private $request;
/**
* @var ClerkLogger
*/
- private ClerkLogger $logger;
+ private $logger;
+ /**
+ * @param RequestInterface $request
+ * @param StoreManagerInterface $storeManager
+ * @param ClerkLogger $logger
+ */
public function __construct(
RequestInterface $request,
StoreManagerInterface $storeManager,
@@ -36,6 +41,8 @@ public function __construct(
}
/**
+ * Get scope frontend context
+ *
* @return string
*/
public function getScope()
@@ -51,6 +58,8 @@ public function getScope()
}
/**
+ * Get scope id frontend context
+ *
* @return int
*/
public function getScopeId()
@@ -66,6 +75,8 @@ public function getScopeId()
}
/**
+ * Get store id
+ *
* @return int
*/
public function getStoreId()
@@ -78,15 +89,28 @@ public function getStoreId()
}
/**
+ * Get store
+ *
+ * @param int|string|void $store_id
* @return StoreInterface|void
*/
- public function getStore()
+ public function getStore($store_id = null)
{
try {
- $params = $this->request->getParams();
- if (array_key_exists('scope_id', $params) && array_key_exists('scope', $params) && $params['scope'] === 'store') {
- $store_id = $params['scope_id'];
+ if (null !== $store_id) {
return $this->storeManager->getStore($store_id);
+ }
+ $params = $this->request->getParams();
+ if (array_key_exists('scope_id', $params)) {
+ if (array_key_exists('scope', $params) && $params['scope'] === 'store') {
+ $store_id = $params['scope_id'];
+ return $this->storeManager->getStore($store_id);
+ } elseif (array_key_exists('store', $params)) {
+ $store_id = $params['store'];
+ return $this->storeManager->getStore($store_id);
+ } else {
+ return $this->storeManager->getStore();
+ }
} elseif (array_key_exists('store', $params)) {
$store_id = $params['store'];
return $this->storeManager->getStore($store_id);
@@ -97,4 +121,40 @@ public function getStore()
$this->logger->error("getStore Error", ['error' => $error->getMessage()]);
}
}
+
+ /**
+ * Get scope admin
+ *
+ * @return string
+ */
+ public function getScopeAdmin()
+ {
+ $params = $this->request->getParams();
+ $scope = 'default';
+ if (array_key_exists('website', $params)) {
+ $scope = 'website';
+ }
+ if (array_key_exists('store', $params)) {
+ $scope = 'store';
+ }
+ return $scope;
+ }
+
+ /**
+ * Get scope id admin
+ *
+ * @return int
+ */
+ public function getScopeIdAdmin()
+ {
+ $params = $this->request->getParams();
+ $scope_id = 0;
+ if (array_key_exists('website', $params)) {
+ $scope_id = (int)$params['website'];
+ }
+ if (array_key_exists('store', $params)) {
+ $scope_id = (int)$params['store'];
+ }
+ return $scope_id;
+ }
}
diff --git a/Helper/Image.php b/Helper/Image.php
index df69cbc..5103014 100644
--- a/Helper/Image.php
+++ b/Helper/Image.php
@@ -2,12 +2,17 @@
namespace Clerk\Clerk\Helper;
+use Clerk\Clerk\Helper\Config as ConfigHelper;
+use Clerk\Clerk\Helper\Context as ContextHelper;
use Clerk\Clerk\Model\Config;
+use Magento\Catalog\Api\Data\ProductInterface;
use Magento\Catalog\Helper\ImageFactory;
use Magento\Catalog\Model\Product;
use Magento\Framework\App\Config\ScopeConfigInterface;
+use Magento\Framework\App\RequestInterface;
+use Magento\Framework\Exception\NoSuchEntityException;
+use Magento\Framework\UrlInterface;
use Magento\Store\Model\StoreManagerInterface;
-use Magento\Store\Model\ScopeInterface;
class Image
{
@@ -29,64 +34,71 @@ class Image
* @var StoreManagerInterface
*/
protected $storeManager;
+ /**
+ * @var ConfigHelper
+ */
+ protected $configHelper;
+ /**
+ * @var ContextHelper
+ */
+ protected $contextHelper;
/**
+ * @param ConfigHelper $configHelper
+ * @param Context $contextHelper
* @param ImageFactory $helperFactory
* @param ScopeConfigInterface $scopeConfig
* @param StoreManagerInterface $storeManager
+ * @param RequestInterface $requestInterface
*/
public function __construct(
- ImageFactory $helperFactory,
- ScopeConfigInterface $scopeConfig,
+ ConfigHelper $configHelper,
+ ContextHelper $contextHelper,
+ ImageFactory $helperFactory,
+ ScopeConfigInterface $scopeConfig,
StoreManagerInterface $storeManager,
- \Magento\Framework\App\RequestInterface $requestInterface
- ) {
+ RequestInterface $requestInterface
+ )
+ {
$this->helperFactory = $helperFactory;
$this->scopeConfig = $scopeConfig;
$this->storeManager = $storeManager;
$this->requestInterface = $requestInterface;
+ $this->contextHelper = $contextHelper;
+ $this->configHelper = $configHelper;
}
/**
* Builds product image URL
*
- * @param Product $item
+ * @param Product|ProductInterface $item
* @return string
+ * @throws NoSuchEntityException
*/
public function getUrl(Product $item)
{
$imageUrl = null;
-
- //Get image thumbnail from settings
- $imageType = $this->scopeConfig->getValue(Config::XML_PATH_PRODUCT_SYNCHRONIZATION_IMAGE_TYPE, ScopeInterface::SCOPE_STORE);
- /** @var \Magento\Catalog\Helper\Image $helper */
+ $imageType = $this->configHelper->getValue(Config::XML_PATH_PRODUCT_SYNCHRONIZATION_IMAGE_TYPE);
$helper = $this->helperFactory->create()->init($item, $imageType);
if ($imageType) {
$imageUrl = $helper->getUrl();
if ($imageUrl == $helper->getDefaultPlaceholderUrl()) {
- // allow to try other types
$imageUrl = null;
}
}
if (!$imageUrl) {
- $_params = $this->requestInterface->getParams();
- if (array_key_exists('scope_id', $_params)){
- $storeId = $_params['scope_id'];
- $store = $this->storeManager->getStore($storeId);
- } else {
- $store = $this->storeManager->getStore();
- }
$itemImage = $item->getImage() ?? $item->getSmallImage() ?? $item->getThumbnail();
-
if ($itemImage === 'no_selection' || !$itemImage) {
$imageUrl = $helper->getDefaultPlaceholderUrl('small_image');
} else {
- $imageUrl = $store->getBaseUrl(\Magento\Framework\UrlInterface::URL_TYPE_MEDIA) . 'catalog/product' . $itemImage;
+ $imageUrl = $this->contextHelper->getStore()->getBaseUrl(UrlInterface::URL_TYPE_MEDIA) . 'catalog/product' . $itemImage;
}
}
-
- return $imageUrl;
+ if (strpos($imageUrl, 'catalog/product/') > -1) {
+ return $imageUrl;
+ }
+ return str_replace('catalog/product', 'catalog/product/', $imageUrl);
}
}
diff --git a/Model/Adapter/AbstractAdapter.php b/Model/Adapter/AbstractAdapter.php
index cd83101..331b761 100644
--- a/Model/Adapter/AbstractAdapter.php
+++ b/Model/Adapter/AbstractAdapter.php
@@ -4,384 +4,409 @@
use Clerk\Clerk\Controller\Logger\ClerkLogger;
use Clerk\Clerk\Model\Config;
+use Exception;
+use Magento\Catalog\Model\ResourceModel\Product\CollectionFactory;
use Magento\Framework\App\Config\ScopeConfigInterface;
use Magento\Framework\Event\ManagerInterface;
use Magento\Store\Model\StoreManagerInterface;
-use Magento\Catalog\Model\ResourceModel\Product\CollectionFactory;
abstract class AbstractAdapter
{
- const PRODUCT_TYPE_SIMPLE = 'simple';
- const PRODUCT_TYPE_CONFIGURABLE = 'configurable';
- const PRODUCT_TYPE_GROUPED = 'grouped';
- const PRODUCT_TYPE_BUNDLE = 'bundle';
- const PRODUCT_TYPES = [
- self::PRODUCT_TYPE_SIMPLE,
- self::PRODUCT_TYPE_CONFIGURABLE,
- self::PRODUCT_TYPE_GROUPED,
- self::PRODUCT_TYPE_BUNDLE
- ];
-
- /**
- * @var ScopeConfigInterface
- */
- protected $scopeConfig;
-
- /**
- * @var
- */
- protected $clerk_logger;
-
- /**
- * @var ManagerInterface
- */
- protected $eventManager;
-
- /**
- * @var StoreManagerInterface
- */
- protected $storeManager;
-
- /**
- * @var mixed
- */
- protected $collectionFactory;
-
- /**
- * @var array
- */
- protected $fieldMap;
-
- /**
- * @var array
- */
- protected $fields = [];
-
- /**
- * @var array
- */
- protected $fieldHandlers = [];
-
- /**
- * AbstractAdapter constructor.
- *
- * @param ScopeConfigInterface $scopeConfig
- * @param ManagerInterface $eventManager
- * @param StoreManagerInterface $storeManager
- * @param mixed $collectionFactory
- */
- public function __construct(
- ScopeConfigInterface $scopeConfig,
- ManagerInterface $eventManager,
- StoreManagerInterface $storeManager,
- CollectionFactory $collectionFactory,
- ClerkLogger $clerk_logger
- ) {
- $this->clerk_logger = $clerk_logger;
- $this->scopeConfig = $scopeConfig;
- $this->eventManager = $eventManager;
- $this->storeManager = $storeManager;
- $this->collectionFactory = $collectionFactory;
- $this->addFieldHandlers();
- }
-
- /**
- * Add default fieldhandlers
- */
- abstract protected function addFieldHandlers();
-
- /**
- * @param $fields
- * @param $page
- * @param $limit
- * @param $orderBy
- * @param $order
- * @param $scope
- * @param $scopeid
- * @return array
- */
- public function getResponse($fields, $page, $limit, $orderBy, $order, $scope, $scopeid)
- {
- try {
-
- if ($this->storeManager->isSingleStoreMode()) {
- $scope = 'store';
- $scopeid = $this->storeManager->getDefaultStoreView()->getId();
- }
-
- $this->setFields($fields, $scope, $scopeid);
-
- $collection = $this->prepareCollection($page, $limit, $orderBy, $order, $scope, $scopeid);
-
- $response = [];
-
- if ($page <= $collection->getLastPageNumber()) {
- //Build response
- foreach ($collection as $resourceItem) {
- $item = $this->getInfoForItem($resourceItem, $scope, $scopeid);
-
- $response[] = $item;
- }
- }
-
- return $response;
-
- } catch (\Exception $e) {
+ public const PRODUCT_TYPE_SIMPLE = 'simple';
+ public const PRODUCT_TYPE_CONFIGURABLE = 'configurable';
+ public const PRODUCT_TYPE_GROUPED = 'grouped';
+ public const PRODUCT_TYPE_BUNDLE = 'bundle';
+ public const PRODUCT_TYPES = [
+ self::PRODUCT_TYPE_SIMPLE,
+ self::PRODUCT_TYPE_CONFIGURABLE,
+ self::PRODUCT_TYPE_GROUPED,
+ self::PRODUCT_TYPE_BUNDLE
+ ];
+
+ /**
+ * @var ScopeConfigInterface
+ */
+ protected $scopeConfig;
+
+ /**
+ * @var ClerkLogger
+ */
+ protected $clerkLogger;
+
+ /**
+ * @var ManagerInterface
+ */
+ protected $eventManager;
+
+ /**
+ * @var StoreManagerInterface
+ */
+ protected $storeManager;
+
+ /**
+ * @var mixed
+ */
+ protected $collectionFactory;
+
+ /**
+ * @var array
+ */
+ protected $fieldMap;
+
+ /**
+ * @var array
+ */
+ protected $fields = [];
+
+ /**
+ * @var array
+ */
+ protected $fieldHandlers = [];
+
+ /**
+ * AbstractAdapter constructor.
+ *
+ * @param ScopeConfigInterface $scopeConfig
+ * @param ManagerInterface $eventManager
+ * @param StoreManagerInterface $storeManager
+ * @param mixed $collectionFactory
+ * @param ClerkLogger $clerkLogger
+ */
+ public function __construct(
+ ScopeConfigInterface $scopeConfig,
+ ManagerInterface $eventManager,
+ StoreManagerInterface $storeManager,
+ CollectionFactory $collectionFactory,
+ ClerkLogger $clerkLogger
+ )
+ {
+ $this->clerkLogger = $clerkLogger;
+ $this->scopeConfig = $scopeConfig;
+ $this->eventManager = $eventManager;
+ $this->storeManager = $storeManager;
+ $this->collectionFactory = $collectionFactory;
+ $this->addFieldHandlers();
+ }
- $this->clerk_logger->error('Getting Response ERROR', ['error' => $e->getMessage()]);
+ /**
+ * Add default fieldhandlers
+ */
+ abstract protected function addFieldHandlers();
+
+ /**
+ * Get request response
+ *
+ * @param array $fields
+ * @param int|string $page
+ * @param int|string $limit
+ * @param int|string $orderBy
+ * @param int|string $order
+ * @param string $scope
+ * @param int|string $scopeid
+ * @return array|void
+ */
+ public function getResponse($fields, $page, $limit, $orderBy, $order, $scope, $scopeid)
+ {
+ try {
+
+ if ($this->storeManager->isSingleStoreMode()) {
+ $scope = 'store';
+ $scopeid = $this->storeManager->getDefaultStoreView()->getId();
+ }
- }
- }
-
- /**
- * @return mixed
- */
- abstract protected function prepareCollection($page, $limit, $orderBy, $order, $scope, $scopeid);
-
- /**
- * Get information for single resource item
- *
- * @param $fields
- * @param $resourceItem
- * @return array
- */
- public function getInfoForItem($resourceItem, $scope, $scopeid)
- {
- try {
-
- $info = array();
- $additionalFields = $this->scopeConfig->getValue(Config::XML_PATH_PRODUCT_SYNCHRONIZATION_ADDITIONAL_FIELDS, $scope, $scopeid);
- $heavyAttributeQuery = $this->scopeConfig->getValue(Config::XML_PATH_PRODUCT_SYNCHRONIZATION_ADDITIONAL_FIELDS_HEAVY_QUERY, $scope, $scopeid);
- $customFields = is_string($additionalFields) ? str_replace(' ', '', explode(',', $additionalFields)) : [];
- $resourceItemTypeId = $resourceItem->getTypeId();
- $resourceItemTypeInstance = $resourceItem->getTypeInstance();
-
- $this->setFields($customFields, $scope, $scopeid);
-
- foreach ($this->getFields() as $field) {
- if (isset($this->fieldHandlers[$field])) {
- $info[$this->getFieldName($field)] = $this->fieldHandlers[$field]($resourceItem);
- }
+ $this->setFields($fields, $scope, $scopeid);
+ $collection = $this->prepareCollection($page, $limit, $orderBy, $order, $scope, $scopeid);
+ $response = [];
+ if ($page <= $collection->getLastPageNumber()) {
+ foreach ($collection as $item) {
+ $response[] = $this->getInfoForItem($item, $scope, $scopeid);
+ }
+ }
+ return $response;
- if (isset($resourceItem[$field]) && !array_key_exists($field, $info)) {
- $attributeValue = $this->getAttributeValue($resourceItem, $field);
- if(!isset($attributeValue) && $heavyAttributeQuery) {
- $attributeValue = $this->getAttributeValueHeavy($resourceItem, $field);
- }
- $info[$this->getFieldName($field)] = $attributeValue;
+ } catch (Exception $e) {
+ $this->clerkLogger->error('Getting Response ERROR', ['error' => $e->getMessage()]);
}
+ }
+ /**
+ * Abstract prepare collection
+ *
+ * @param int|string $page
+ * @param int|string $limit
+ * @param int|string $orderBy
+ * @param int|string $order
+ * @param string $scope
+ * @param int|string $scopeid
+ * @return mixed
+ */
+ abstract protected function prepareCollection($page, $limit, $orderBy, $order, $scope, $scopeid);
+
+ /**
+ * Get information for single resource item
+ *
+ * @param object $resourceItem
+ * @param string $scope
+ * @param int|string $scopeid
+ * @return array|void
+ */
+ public function getInfoForItem($resourceItem, $scope, $scopeid)
+ {
+ try {
+
+ $info = [];
+ $additional_fields =
+ $this->scopeConfig->getValue(
+ Config::XML_PATH_PRODUCT_SYNCHRONIZATION_ADDITIONAL_FIELDS,
+ $scope,
+ $scopeid
+ );
+ $emulate_inactive_products =
+ $this->scopeConfig->getValue(
+ Config::XML_PATH_PRODUCT_SYNCHRONIZATION_ADDITIONAL_FIELDS_HEAVY_QUERY,
+ $scope,
+ $scopeid
+ );
+ $custom_fields = is_string($additional_fields) ? array_map('trim', explode(',', $additional_fields)) : [];
+ $resource_item_type_id = $resourceItem->getTypeId();
+ $resource_item_type_instance = $resourceItem->getTypeInstance();
+
+ $this->setFields($custom_fields, $scope, $scopeid);
+
+ foreach ($this->getFields() as $field) {
+ if (isset($this->fieldHandlers[$field])) {
+ $info[$this->getFieldName($field)] = $this->fieldHandlers[$field]($resourceItem);
+ }
+ if (isset($resourceItem[$field]) && !array_key_exists($field, $info)) {
+ $attribute_value = $this->getAttributeValue($resourceItem, $field);
+ if (!isset($attribute_value) && $emulate_inactive_products) {
+ $attribute_value = $this->getAttributeValueHeavy($resourceItem, $field);
+ }
+ $info[$this->getFieldName($field)] = $attribute_value;
+ }
- if ($resourceItemTypeId === self::PRODUCT_TYPE_CONFIGURABLE) {
- $usedProductsAttributeValues = array();
- $entityField = 'entity_'.$field;
- $usedProducts = $resourceItemTypeInstance->getUsedProducts($resourceItem);
- if ( ! empty($usedProducts) ){
- foreach ($usedProducts as $usedProduct) {
- if (isset($usedProduct[$field])) {
- $usedProductsAttributeValues[] = $this->getAttributeValue($usedProduct, $field);
- } elseif (isset($usedProduct[$entityField])) {
- $usedProductsAttributeValues[] = $this->getAttributeValue($usedProduct, $entityField);
- }
- if(empty($usedProductsAttributeValues) && $heavyAttributeQuery) {
- $attributeValue = $this->getAttributeValueHeavy($usedProduct, $field);
- if(isset($attributeValue)){
- $usedProductsAttributeValues[] = $attributeValue;
+ if ($resource_item_type_id === self::PRODUCT_TYPE_CONFIGURABLE) {
+ $used_products = $resource_item_type_instance->getUsedProducts($resourceItem);
+ $info = $this->getChildAttributes($used_products, $info, $field, $emulate_inactive_products);
}
- }
- }
- }
- if ( ! empty($usedProductsAttributeValues) && !array_key_exists('child_'.$this->getFieldName($field).'s', $info) ) {
- $usedProductsAttributeValues = is_array($usedProductsAttributeValues) ? $this->flattenArray($usedProductsAttributeValues) : $usedProductsAttributeValues;
- $info["child_".$this->getFieldName($field)."s"] = $usedProductsAttributeValues;
- }
- }
- if ($resourceItemTypeId === self::PRODUCT_TYPE_GROUPED) {
- $associatedProductsAttributeValues = array();
- $entityField = 'entity_'.$field;
- $associatedProducts = $resourceItemTypeInstance->getAssociatedProducts($resourceItem);
- if ( ! empty($associatedProducts) ) {
- foreach ($associatedProducts as $associatedProduct) {
- if (isset($associatedProduct[$field])) {
- $associatedProductsAttributeValues[] = $this->getAttributeValue($associatedProduct, $field);
- } elseif (isset($associatedProduct[$entityField])) {
- $associatedProductsAttributeValues[] = $this->getAttributeValue($associatedProduct, $entityField);
- }
- if(empty($associatedProductsAttributeValues) && $heavyAttributeQuery) {
- $attributeValue = $this->getAttributeValueHeavy($associatedProduct, $field);
- if(isset($attributeValue)){
- $associatedProductsAttributeValues[] = $attributeValue;
+ if ($resource_item_type_id === self::PRODUCT_TYPE_GROUPED) {
+ $associated_products = $resource_item_type_instance->getAssociatedProducts($resourceItem);
+ $info = $this->getChildAttributes($associated_products, $info, $field, $emulate_inactive_products);
}
+ }
- }
+ if (isset($info['price']) && isset($info['list_price'])) {
+ $info['on_sale'] = $info['price'] < $info['list_price'];
}
- }
- if ( ! empty($associatedProductsAttributeValues) && !array_key_exists('child_'.$this->getFieldName($field).'s', $info)) {
- $associatedProductsAttributeValues = is_array($associatedProductsAttributeValues) ? $this->flattenArray($associatedProductsAttributeValues) : $associatedProductsAttributeValues;
- $info["child_".$this->getFieldName($field)."s"] = $associatedProductsAttributeValues;
- }
+ // Fix for bundle products not reliably having implicit tax.
+ $info = $this->fixForBundleProductsNotReliablyHavingImplicitTax($info);
+
+ // Fix for including a list of Bundle Products child skus.
+ if ($resource_item_type_id == self::PRODUCT_TYPE_BUNDLE) {
+ $bundle_skus = [];
+ $selections = $resourceItem->getTypeInstance(true)->getSelectionsCollection(
+ $resourceItem->getTypeInstance(true)->getOptionsIds($resourceItem),
+ $resourceItem
+ );
+ if (!empty($selections)) {
+ foreach ($selections as $selection) {
+ if (is_object($selection)) {
+ $bundle_skus[] = $selection->getSku();
+ }
+ }
+ }
+ $info['bundle_skus'] = $bundle_skus;
+ }
+ return $info;
+ } catch (Exception $e) {
+ $this->clerkLogger->error('Getting Response ERROR', ['error' => $e->getMessage()]);
}
- }
-
- if(isset($info['price']) && isset($info['list_price'])){
- $info['on_sale'] = (bool) ($info['price'] < $info['list_price']);
- }
-
- // Fix for bundle products not reliably having implicit tax.
- if(isset($info['tax_rate']) && $info['product_type'] == self::PRODUCT_TYPE_BUNDLE){
- if($info['price'] === $info['price_excl_tax']){
- $info['price_excl_tax'] = $info['price'] / (1 + ($info['tax_rate'] / 100) );
- }
- if($info['list_price'] === $info['list_price_excl_tax']){
- $info['list_price_excl_tax'] = $info['list_price'] / (1 + ($info['tax_rate'] / 100) );
- }
- }
-
- // Fix for including a list of Bundle Products child skus.
- if($resourceItemTypeId == self::PRODUCT_TYPE_BUNDLE){
- $bundle_skus = [];
- $selections = $resourceItem->getTypeInstance(true)->getSelectionsCollection($resourceItem->getTypeInstance(true)->getOptionsIds($resourceItem), $resourceItem);
- if( !empty($selections) ){
- foreach($selections as $selection){
- if( is_object($selection) ){
- $bundle_skus[] = $selection->getSku();
- }
- }
+ }
+
+ /**
+ * Get an array of fields
+ *
+ * @return array
+ */
+ public function getFields()
+ {
+ return $this->fields;
+ }
+
+ /**
+ * Set fields to get
+ *
+ * @param array $fields
+ * @param string $scope
+ * @param int|string $scopeid
+ */
+ public function setFields($fields, $scope, $scopeid)
+ {
+ $this->fields = array_merge(['entity_id'], $this->getDefaultFields($scope, $scopeid), (array)$fields);
+ }
+
+ /**
+ * Get mapped field name
+ *
+ * @param string $field
+ * @return mixed
+ */
+ protected function getFieldName($field)
+ {
+ if (isset($this->fieldMap[$field])) {
+ return $this->fieldMap[$field];
}
- $info['bundle_skus'] = $bundle_skus;
- }
- return $info;
- } catch (\Exception $e) {
+ return $field;
+ }
+
+ /**
+ * Get attribute value
+ *
+ * @param object $resourceItem
+ * @param string $field
+ * @return mixed
+ */
+ protected function getAttributeValue($resourceItem, $field)
+ {
+ return $resourceItem[$field];
+ }
- $this->clerk_logger->error('Getting Response ERROR', ['error' => $e->getMessage()]);
+ /**
+ * Get attribute value for product by simulating resource
+ *
+ * @param object $resourceItem
+ * @param string $field
+ * @return mixed|void
+ */
+ public function getAttributeValueHeavy($resourceItem, $field)
+ {
+ try {
+
+ $attribute_resource = $resourceItem->getResource();
+
+ if (in_array($resourceItem->getTypeId(), self::PRODUCT_TYPES)) {
+ $attribute_resource->load($resourceItem, $resourceItem->getId(), [$field]);
+
+ $attribute = $resourceItem->getCustomAttribute($field);
+ if ($attribute) {
+ return $attribute->getValue();
+ }
+ }
+ } catch (Exception $e) {
+ $this->clerkLogger->error('Getting Attribute Value Error', ['error' => $e->getMessage()]);
+ }
}
- }
-
- /**
- * Get list of fields
- *
- * @return array
- */
- public function getFields()
- {
- return $this->fields;
- }
-
- /**
- * Set fields to get
- *
- * @param $fields
- */
- public function setFields($fields, $scope, $scopeid)
- {
- $this->fields = array_merge(['entity_id'], $this->getDefaultFields($scope, $scopeid), (array)$fields);
- }
-
- /**
- * Get mapped field name
- *
- * @param $field
- * @return mixed
- */
- protected function getFieldName($field)
- {
- if (isset($this->fieldMap[$field])) {
- return $this->fieldMap[$field];
+
+ /**
+ * Get child attributes
+ *
+ * @param array $related_products
+ * @param array $export_data
+ * @param string $field
+ * @param bool $emulate_deactivated
+ * @return array
+ */
+ public function getChildAttributes($related_products, $export_data, $field, $emulate_deactivated)
+ {
+ $child_attribute_values = [];
+ $entity_field = 'entity_' . $field;
+ if (empty($related_products)) {
+ return $export_data;
+ }
+ foreach ($related_products as $related_product) {
+ if (isset($related_product[$field])) {
+ $child_attribute_values[] = $this->getAttributeValue($related_product, $field);
+ } elseif (isset($related_product[$entity_field])) {
+ $child_attribute_values[] = $this->getAttributeValue($related_product, $entity_field);
+ }
+ if (empty($child_attribute_values) && $emulate_deactivated) {
+ $attribute_value = $this->getAttributeValueHeavy($related_product, $field);
+ if (isset($attribute_value)) {
+ $child_attribute_values[] = $attribute_value;
+ }
+ }
+ }
+ $attribute_key = 'child_' . $this->getFieldName($field) . 's';
+ if (!empty($child_attribute_values) && !array_key_exists($attribute_key, $export_data)) {
+ $child_attribute_values = $this->flattenArray($child_attribute_values);
+ $export_data[$attribute_key] = $child_attribute_values;
+
+ }
+ return $export_data;
}
- return $field;
- }
-
- /**
- * Get attribute value
- *
- * @param $resourceItem
- * @param $field
- * @return mixed
- */
- protected function getAttributeValue($resourceItem, $field)
- {
- return $resourceItem[$field];
- }
-
- /**
- * Add field to get
- *
- * @param $field
- */
- public function addField($field)
- {
- $this->fields[] = $field;
- }
-
- /**
- * Add fieldhandler
- *
- * @param $field
- * @param callable $handler
- */
- public function addFieldHandler($field, callable $handler)
- {
- $this->fieldHandlers[$field] = $handler;
- }
-
- /**
- * Flatten array
- *
- * @param array $array
- * @return array $array
- */
- public function flattenArray($array)
- {
- $return = [];
- array_walk_recursive($array, function ($a) use (&$return) {
- $return[] = $a;
- });
- return $return;
- }
-
- /**
- * Get attribute value for product by simulating resource
- *
- * @param $resourceItem
- * @param $field
- * @return mixed
- */
- public function getAttributeValueHeavy($resourceItem, $field)
- {
- try {
-
- $attributeResource = $resourceItem->getResource();
-
- if(in_array($resourceItem->getTypeId(), self::PRODUCT_TYPES)){
- $attributeResource->load($resourceItem, $resourceItem->getId(), [$field]);
-
- $customAttribute = $resourceItem->getCustomAttribute($field);
- if($customAttribute){
- return $customAttribute->getValue();
+ /**
+ * Flatten array
+ *
+ * @param array $array
+ * @return array $array
+ */
+ public function flattenArray($array)
+ {
+ if (is_object($array)) {
+ $array = (array)$array;
+ }
+ if (!is_array($array)) {
+ return $array;
}
- }
+ $return = [];
+ array_walk_recursive($array, function ($a) use (&$return) {
+ $return[] = $a;
+ });
+ return $return;
+ }
- } catch (\Exception $e) {
+ /**
+ * @param array $info
+ * @return array
+ */
+ public function fixForBundleProductsNotReliablyHavingImplicitTax(array $info): array
+ {
+ if (isset($info['tax_rate']) && $info['product_type'] == self::PRODUCT_TYPE_BUNDLE) {
+ if ($info['price'] === $info['price_excl_tax']) {
+ $info['price_excl_tax'] = $info['price'] / (1 + ($info['tax_rate'] / 100));
+ }
+ if ($info['list_price'] === $info['list_price_excl_tax']) {
+ $info['list_price_excl_tax'] = $info['list_price'] / (1 + ($info['tax_rate'] / 100));
+ }
+ }
+ return $info;
+ }
- $this->clerk_logger->error('Getting Attribute Value Error', ['error' => $e->getMessage()]);
+ /**
+ * Add field to get
+ *
+ * @param string $field
+ */
+ public function addField($field)
+ {
+ $this->fields[] = $field;
+ }
+ /**
+ * Add fieldhandler
+ *
+ * @param string $field
+ * @param callable $handler
+ */
+ public function addFieldHandler($field, callable $handler)
+ {
+ $this->fieldHandlers[$field] = $handler;
}
- }
-
- /**
- * Get default fields
- *
- * @param string $scope
- * @param int|string $scopeid
- * @return array
- */
- abstract protected function getDefaultFields($scope, $scopeid);
+
+ /**
+ * Get default fields
+ *
+ * @param string $scope
+ * @param int|string $scopeid
+ * @return array
+ */
+ abstract protected function getDefaultFields($scope, $scopeid);
}
diff --git a/Model/Adapter/Product.php b/Model/Adapter/Product.php
index 020a145..76b961a 100644
--- a/Model/Adapter/Product.php
+++ b/Model/Adapter/Product.php
@@ -3,6 +3,7 @@
namespace Clerk\Clerk\Model\Adapter;
use Clerk\Clerk\Controller\Logger\ClerkLogger;
+use Clerk\Clerk\Helper\Context as ContextHelper;
use Clerk\Clerk\Helper\Image;
use Clerk\Clerk\Model\Config;
use Exception;
@@ -18,60 +19,48 @@
use Magento\Framework\Event\ManagerInterface;
use Magento\Framework\Module\Manager as ModuleManager;
use Magento\Framework\ObjectManagerInterface;
+use Magento\Store\Model\ScopeInterface;
use Magento\Store\Model\StoreManagerInterface;
-use Magento\Tax\Model\Calculation\Rate as TaxRate;
+use Magento\Tax\Model\Calculation\RateFactory as TaxRateFactory;
class Product extends AbstractAdapter
{
- const PRODUCT_TYPE_SIMPLE = 'simple';
- const PRODUCT_TYPE_CONFIGURABLE = 'configurable';
- const PRODUCT_TYPE_GROUPED = 'grouped';
- const PRODUCT_TYPE_BUNDLE = 'bundle';
- const PRODUCT_TYPES = [
+ public const PRODUCT_TYPE_SIMPLE = 'simple';
+ public const PRODUCT_TYPE_CONFIGURABLE = 'configurable';
+ public const PRODUCT_TYPE_GROUPED = 'grouped';
+ public const PRODUCT_TYPE_BUNDLE = 'bundle';
+ public const PRODUCT_TYPES = [
self::PRODUCT_TYPE_SIMPLE,
self::PRODUCT_TYPE_CONFIGURABLE,
self::PRODUCT_TYPE_GROUPED,
self::PRODUCT_TYPE_BUNDLE
];
-
/**
* @var ProductRepositoryInterface;
*/
protected $_productRepository;
-
/**
- * @var TaxRate;
+ * @var TaxRateFactory;
*/
- protected $taxRate;
-
+ protected $taxRateFactory;
/**
- * @var null
+ * @var array|object
*/
protected $productTaxRates;
- /**
- * @var ItemSource
- */
- protected $itemSource;
-
/**
* @var StockFilter
*/
protected $stockFilter;
- /**
- * @var GetSalableQuantityDataBySku
- */
- protected $getSalableQuantityDataBySku;
-
/**
* @var LoggerInterface
*/
- protected $clerk_logger;
+ protected $clerkLogger;
/**
* @var RequestInterface
@@ -102,11 +91,6 @@ class Product extends AbstractAdapter
*/
protected $eventPrefix = 'product';
- /**
- * @var StoreManagerInterface
- */
- protected $storeManager;
-
/**
* @var Data
*/
@@ -130,24 +114,40 @@ class Product extends AbstractAdapter
* @var bool
*/
protected $msiEnabled;
+ /**
+ * @var string
+ */
+ protected $scope;
+ /**
+ * @var int|string
+ */
+ protected $scopeId;
+ /**
+ * @var ContextHelper
+ */
+ protected $contextHelper;
+ /**
+ * @var array
+ */
+ protected $exportProduct;
/**
- * Summary of __construct
* @param ScopeConfigInterface $scopeConfig
* @param ManagerInterface $eventManager
* @param CollectionFactory $collectionFactory
* @param StoreManagerInterface $storeManager
* @param Image $imageHelper
* @param ClerkLogger $clerkLogger
- * @param Stock $stockFilter
+ * @param StockFilter $stockFilter
* @param Data $taxHelper
* @param StockStateInterface $stockStateInterface
* @param ProductMetadataInterface $productMetadataInterface
* @param RequestInterface $requestInterface
- * @param GetSalableQuantityDataBySku $getSalableQuantityDataBySku
- * @param ItemSource $itemSource
- * @param Rate $taxRate
+ * @param TaxRateFactory $taxRate
* @param ProductRepositoryInterface $productRepository
+ * @param ModuleManager $moduleManager
+ * @param ObjectManagerInterface $objectManager
+ * @param ContextHelper $contextHelper
*/
public function __construct(
ScopeConfigInterface $scopeConfig,
@@ -161,26 +161,29 @@ public function __construct(
StockStateInterface $stockStateInterface,
ProductMetadataInterface $productMetadataInterface,
RequestInterface $requestInterface,
- TaxRate $taxRate,
+ TaxRateFactory $taxRate,
ProductRepositoryInterface $productRepository,
ModuleManager $moduleManager,
- ObjectManagerInterface $objectManager
+ ObjectManagerInterface $objectManager,
+ ContextHelper $contextHelper
)
{
$this->taxHelper = $taxHelper;
$this->stockFilter = $stockFilter;
- $this->clerk_logger = $clerkLogger;
+ $this->clerkLogger = $clerkLogger;
$this->imageHelper = $imageHelper;
- $this->storeManager = $storeManager;
$this->moduleManager = $moduleManager;
$this->objectManager = $objectManager;
$this->stockStateInterface = $stockStateInterface;
$this->productMetadataInterface = $productMetadataInterface;
$this->requestInterface = $requestInterface;
- $this->taxRate = $taxRate;
- $this->productTaxRates = $this->taxRate->getCollection()->getData();
+ $this->taxRateFactory = $taxRate;
+ $this->productTaxRates = $this->taxRateFactory->create()->getData();
$this->_productRepository = $productRepository;
- $this->msiEnabled = $this->moduleManager->isEnabled('Magento_Inventory') && $this->moduleManager->isEnabled('Magento_InventoryAdminUi');
+ $this->contextHelper = $contextHelper;
+ $this->msiEnabled = $this->moduleManager->isEnabled('Magento_Inventory')
+ && $this->moduleManager->isEnabled('Magento_InventoryAdminUi');
+ $this->exportProduct = [];
parent::__construct(
$scopeConfig,
$eventManager,
@@ -193,7 +196,13 @@ public function __construct(
/**
* Prepare collection
*
- * @return mixed
+ * @param int|string $page
+ * @param int|string $limit
+ * @param int|string $orderBy
+ * @param int|string $order
+ * @param string $scope
+ * @param int|string $scopeid
+ * @return mixed|void
*/
protected function prepareCollection($page, $limit, $orderBy, $order, $scope, $scopeid)
{
@@ -206,23 +215,19 @@ protected function prepareCollection($page, $limit, $orderBy, $order, $scope, $s
$productMetadata = $this->productMetadataInterface;
$version = $productMetadata->getVersion();
- if (!$version >= '2.3.3') {
-
- //Filter on is_saleable if defined
- if ($this->scopeConfig->getValue(Config::XML_PATH_PRODUCT_SYNCHRONIZATION_SALABLE_ONLY, $scope, $scopeid)) {
+ if ($this->scopeConfig->getValue(Config::XML_PATH_PRODUCT_SYNCHRONIZATION_SALABLE_ONLY, $scope, $scopeid)) {
+ if (!$version >= '2.3.3') {
$this->stockFilter->addInStockFilterToCollection($collection);
- }
-
-
- } else {
-
- if (!$this->scopeConfig->getValue(Config::XML_PATH_PRODUCT_SYNCHRONIZATION_SALABLE_ONLY, $scope, $scopeid)) {
+ } else {
$collection->setFlag('has_stock_status_filter', true);
}
-
}
- $visibility = $this->scopeConfig->getValue(Config::XML_PATH_PRODUCT_SYNCHRONIZATION_VISIBILITY, $scope, $scopeid);
+ $visibility = $this->scopeConfig->getValue(
+ Config::XML_PATH_PRODUCT_SYNCHRONIZATION_VISIBILITY,
+ $scope,
+ $scopeid
+ );
switch ($visibility) {
case Visibility::VISIBILITY_IN_CATALOG:
@@ -235,7 +240,11 @@ protected function prepareCollection($page, $limit, $orderBy, $order, $scope, $s
$collection->setVisibility([Visibility::VISIBILITY_BOTH]);
break;
case 'any':
- $collection->addAttributeToFilter('visibility', ['in' => [Visibility::VISIBILITY_IN_CATALOG, Visibility::VISIBILITY_IN_SEARCH, Visibility::VISIBILITY_BOTH]]);
+ $collection->addAttributeToFilter('visibility', ['in' => [
+ Visibility::VISIBILITY_IN_CATALOG,
+ Visibility::VISIBILITY_IN_SEARCH,
+ Visibility::VISIBILITY_BOTH
+ ]]);
break;
}
@@ -249,26 +258,24 @@ protected function prepareCollection($page, $limit, $orderBy, $order, $scope, $s
return $collection;
} catch (Exception $e) {
-
- $this->clerk_logger->error('Prepare Collection Error', ['error' => $e->getMessage()]);
-
+ $this->clerkLogger->error('Prepare Collection Error', ['error' => $e->getMessage()]);
}
}
/**
- * Add field handlers for products
+ * Add field handlers
+ *
+ * @return void
*/
protected function addFieldHandlers()
{
try {
- //Add age fieldhandler
$this->addFieldHandler('age', function ($item) {
return floor((time() - strtotime($item->getCreatedAt())) / (60 * 60 * 24));
});
- //Add created_at fieldhandler
$this->addFieldHandler('created_at', function ($item) {
return strtotime($item->getCreatedAt());
});
@@ -286,7 +293,7 @@ protected function addFieldHandlers()
});
$this->addFieldHandler('description', function ($item) {
- return $this->getAttributeValue($item, 'description') ? str_replace(array("\r", "\n"), ' ', strip_tags(html_entity_decode($this->getAttributeValue($item, 'description')))) : '';
+ return $this->getAttributeValue($item, 'description') ? str_replace(["\r", "\n"], ' ', strip_tags(html_entity_decode($this->getAttributeValue($item, 'description')))) : '';
});
$this->addFieldhandler('visibility', function ($item) {
@@ -335,7 +342,7 @@ protected function addFieldHandlers()
return $this->formatPrice($item->getPriceInfo()->getPrice('final_price')->getMinimalPrice()->getValue());
}
if ($productType == self::PRODUCT_TYPE_CONFIGURABLE) {
- $childPrices = array();
+ $childPrices = [];
$childProducts = $productTypeInstance->getUsedProducts($item);
if (!empty($childProducts)) {
foreach ($childProducts as $childProduct) {
@@ -351,7 +358,7 @@ protected function addFieldHandlers()
}
}
} catch (Exception $e) {
- $this->clerk_logger->error('Getting Product Price Error', ['error' => $e->getMessage()]);
+ $this->clerkLogger->error('Getting Product Price Error', ['error' => $e->getMessage()]);
}
});
@@ -388,7 +395,7 @@ protected function addFieldHandlers()
return $this->formatPrice($item->getPriceInfo()->getPrice('final_price')->getMinimalPrice()->getValue());
}
if ($productType == self::PRODUCT_TYPE_CONFIGURABLE) {
- $childPrices = array();
+ $childPrices = [];
$childProducts = $productTypeInstance->getUsedProducts($item);
if (!empty($childProducts)) {
foreach ($childProducts as $childProduct) {
@@ -404,7 +411,7 @@ protected function addFieldHandlers()
}
}
} catch (Exception $e) {
- $this->clerk_logger->error('Getting Product Price Exc Tax Error', ['error' => $e->getMessage()]);
+ $this->clerkLogger->error('Getting Product Price Exc Tax Error', ['error' => $e->getMessage()]);
}
});
@@ -440,7 +447,7 @@ protected function addFieldHandlers()
return $this->formatPrice($item->getPriceInfo()->getPrice('regular_price')->getMinimalPrice()->getValue());
}
if ($productType == self::PRODUCT_TYPE_CONFIGURABLE) {
- $childPrices = array();
+ $childPrices = [];
$childProducts = $productTypeInstance->getUsedProducts($item);
if (!empty($childProducts)) {
foreach ($childProducts as $childProduct) {
@@ -456,7 +463,7 @@ protected function addFieldHandlers()
}
}
} catch (Exception $e) {
- $this->clerk_logger->error('Getting Product List Price Error', ['error' => $e->getMessage()]);
+ $this->clerkLogger->error('Getting Product List Price Error', ['error' => $e->getMessage()]);
}
});
@@ -491,7 +498,7 @@ protected function addFieldHandlers()
return $this->formatPrice($item->getPriceInfo()->getPrice('regular_price')->getMinimalPrice()->getValue());
}
if ($productType == self::PRODUCT_TYPE_CONFIGURABLE) {
- $childPrices = array();
+ $childPrices = [];
$childProducts = $productTypeInstance->getUsedProducts($item);
if (!empty($childProducts)) {
foreach ($childProducts as $childProduct) {
@@ -507,12 +514,12 @@ protected function addFieldHandlers()
}
}
} catch (Exception $e) {
- $this->clerk_logger->error('Getting Product List Price Exc Tax Error', ['error' => $e->getMessage()]);
+ $this->clerkLogger->error('Getting Product List Price Exc Tax Error', ['error' => $e->getMessage()]);
}
});
$this->addFieldHandler('tier_price_values', function ($item) {
- $tierPriceValues = array();
+ $tierPriceValues = [];
$tierPrices = $item->getTierPrice();
if (!empty($tierPrices)) {
foreach ($tierPrices as $tierPrice) {
@@ -525,7 +532,7 @@ protected function addFieldHandlers()
});
$this->addFieldHandler('tier_price_quantities', function ($item) {
- $tierPriceQuantities = array();
+ $tierPriceQuantities = [];
$tierPrices = $item->getTierPrice();
if (!empty($tierPrices)) {
foreach ($tierPrices as $tierPrice) {
@@ -539,13 +546,12 @@ protected function addFieldHandlers()
//Add image fieldhandler
$this->addFieldHandler('image', function ($item) {
- return $this->fixImagePath($this->imageHelper->getUrl($item));
+ return $this->imageHelper->getUrl($item);
});
//Add url fieldhandler
$this->addFieldHandler('url', function ($item) {
- $storeId = $this->getStoreIdFromContext();
- return $item->setStoreId($storeId)->getUrlInStore();
+ return $item->setStoreId($item->scopeId)->getUrlInStore();
});
//Add categories fieldhandler
@@ -556,7 +562,7 @@ protected function addFieldHandlers()
$this->addFieldHandler('child_stocks', function ($item) {
$productType = $item->getTypeID();
$productTypeInstance = $item->getTypeInstance();
- $stockValues = array();
+ $stockValues = [];
if ($productType == self::PRODUCT_TYPE_CONFIGURABLE) {
$usedProducts = $productTypeInstance->getUsedProducts($item);
foreach ($usedProducts as $usedProduct) {
@@ -575,7 +581,7 @@ protected function addFieldHandlers()
$this->addFieldHandler('child_prices', function ($item) {
$productType = $item->getTypeID();
$productTypeInstance = $item->getTypeInstance();
- $childPrices = array();
+ $childPrices = [];
if ($productType == self::PRODUCT_TYPE_CONFIGURABLE) {
$usedProducts = $productTypeInstance->getUsedProducts($item);
foreach ($usedProducts as $usedProduct) {
@@ -594,7 +600,7 @@ protected function addFieldHandlers()
$this->addFieldHandler('child_list_prices', function ($item) {
$productType = $item->getTypeID();
$productTypeInstance = $item->getTypeInstance();
- $childPrices = array();
+ $childPrices = [];
if ($productType == self::PRODUCT_TYPE_CONFIGURABLE) {
$usedProducts = $productTypeInstance->getUsedProducts($item);
foreach ($usedProducts as $usedProduct) {
@@ -611,10 +617,10 @@ protected function addFieldHandlers()
});
$this->addFieldHandler('child_images', function ($item) {
- $heavyAttributeQuery = $this->scopeConfig->getValue(Config::XML_PATH_PRODUCT_SYNCHRONIZATION_ADDITIONAL_FIELDS_HEAVY_QUERY, 'store', $this->getStoreIdFromContext());
+ $heavyAttributeQuery = $this->scopeConfig->getValue(Config::XML_PATH_PRODUCT_SYNCHRONIZATION_ADDITIONAL_FIELDS_HEAVY_QUERY, ScopeInterface::SCOPE_STORE, $this->scopeId);
$productType = $item->getTypeID();
$productTypeInstance = $item->getTypeInstance();
- $childImages = array();
+ $childImages = [];
if ($productType == self::PRODUCT_TYPE_CONFIGURABLE) {
if ($heavyAttributeQuery) {
$childIdsRaw = $productTypeInstance->getChildrenIds($item->getId());
@@ -625,22 +631,24 @@ protected function addFieldHandlers()
$childIds = $childIdsRaw;
}
}
- foreach ($childIds as $childId) {
- // Emulate product even if disabled
- $childProduct = $this->_productRepository->getById($childId);
- $childImages[] = $this->fixImagePath($this->imageHelper->getUrl($childProduct));
+ if (!empty($childIds)) {
+ foreach ($childIds as $childId) {
+ // Emulate product even if disabled
+ $childProduct = $this->_productRepository->getById($childId);
+ $childImages[] = $this->imageHelper->getUrl($childProduct);
+ }
}
} else {
$usedProducts = $productTypeInstance->getUsedProducts($item);
foreach ($usedProducts as $usedProduct) {
- $childImages[] = $this->fixImagePath($this->imageHelper->getUrl($usedProduct));
+ $childImages[] = $this->imageHelper->getUrl($usedProduct);
}
}
}
if ($productType == self::PRODUCT_TYPE_GROUPED) {
$associatedProducts = $productTypeInstance->getAssociatedProducts($item);
foreach ($associatedProducts as $associatedProduct) {
- $childImages[] = $this->fixImagePath($this->imageHelper->getUrl($associatedProduct));
+ $childImages[] = $this->imageHelper->getUrl($associatedProduct);
}
}
return $childImages;
@@ -654,42 +662,28 @@ protected function addFieldHandlers()
if ($productType == self::PRODUCT_TYPE_SIMPLE || !in_array($productType, self::PRODUCT_TYPES)) {
$productStock = $this->getProductStockStateQty($item);
- // If stock was 0, try to get it without looking at the scope.
- //if($productStock == 0){
- // $productStock = $this->getSaleableStockBySku($item->getSku());
- //}
}
if ($productType == self::PRODUCT_TYPE_CONFIGURABLE) {
$usedProducts = $productTypeInstance->getUsedProducts($item);
foreach ($usedProducts as $usedProduct) {
$productStock += $this->getProductStockStateQty($usedProduct);
}
- //if($productStock == 0){
- // foreach ($usedProducts as $usedProduct) {
- // $productStock += $this->getSaleableStockBySku($usedProduct->getSku());
- // }
- //}
}
if ($productType == self::PRODUCT_TYPE_GROUPED) {
$associatedProducts = $productTypeInstance->getAssociatedProducts($item);
foreach ($associatedProducts as $associatedProduct) {
$productStock += $this->getProductStockStateQty($associatedProduct);
}
- //if($productStock == 0){
- // foreach($associatedProducts as $associatedProduct){
- // $productStock += $this->getSaleableStockBySku($associatedProduct->getSku());
- // }
- //}
}
if ($productType == self::PRODUCT_TYPE_BUNDLE) {
- $productsArray = array();
+ $productsArray = [];
$selectionCollection = $item->getTypeInstance(true)->getSelectionsCollection(
$item->getTypeInstance(true)->getOptionsIds($item),
$item
);
foreach ($selectionCollection as $proselection) {
- $selectionArray = array();
+ $selectionArray = [];
$selectionArray['min_qty'] = $proselection->getSelectionQty();
$selectionArray['stock'] = $this->stockStateInterface->getStockQty($proselection->getProductId(), $item->getStore()->getWebsiteId());
$productsArray[$proselection->getOptionId()][$proselection->getSelectionId()] = $selectionArray;
@@ -733,17 +727,17 @@ protected function addFieldHandlers()
}
}
if ($productType == self::PRODUCT_TYPE_BUNDLE) {
- $productsArray = array();
- $selectionCollection = $item->getTypeInstance(true)->getSelectionsCollection(
+ $productsArray = [];
+ $product_selection_collection = $item->getTypeInstance(true)->getSelectionsCollection(
$item->getTypeInstance(true)->getOptionsIds($item),
$item
);
- foreach ($selectionCollection as $proselection) {
- $selectionArray = array();
- $selectionArray['min_qty'] = $proselection->getSelectionQty();
- $selectionArray['stock'] = $this->stockStateInterface->getStockQty($proselection->getProductId(), $item->getStore()->getWebsiteId());
- $productsArray[$proselection->getOptionId()][$proselection->getSelectionId()] = $selectionArray;
+ foreach ($product_selection_collection as $product_selection) {
+ $selectionArray = [];
+ $selectionArray['min_qty'] = $product_selection->getSelectionQty();
+ $selectionArray['stock'] = $this->stockStateInterface->getStockQty($product_selection->getProductId(), $item->getStore()->getWebsiteId());
+ $productsArray[$product_selection->getOptionId()][$product_selection->getSelectionId()] = $selectionArray;
}
$bundle_stock = 0;
@@ -765,7 +759,7 @@ protected function addFieldHandlers()
});
} catch (Exception $e) {
- $this->clerk_logger->error('Getting Field Handlers Error', ['error' => $e->getMessage()]);
+ $this->clerkLogger->error('Getting Field Handlers Error', ['error' => $e->getMessage()]);
}
}
@@ -774,20 +768,16 @@ protected function addFieldHandlers()
*
* @param $resourceItem
* @param $field
- * @return mixed
+ * @return mixed|void
*/
protected function getAttributeValue($resourceItem, $field)
{
try {
-
$attributeResource = $resourceItem->getResource();
-
if (!$attributeResource) {
return parent::getAttributeValue($resourceItem, $field);
}
-
$attribute = $attributeResource->getAttribute($field);
-
if (!is_bool($attribute) && is_object($attribute)) {
if ($attribute->usesSource()) {
$source = $attribute->getSource();
@@ -796,20 +786,16 @@ protected function getAttributeValue($resourceItem, $field)
}
}
}
-
return parent::getAttributeValue($resourceItem, $field);
-
} catch (Exception $e) {
-
- $this->clerk_logger->error('Getting Attribute Value Error', ['error' => $e->getMessage()]);
-
+ $this->clerkLogger->error('Getting Attribute Value Error', ['error' => $e->getMessage()]);
}
}
/**
* Format Price to 2 decimals
* @param float|int $price
- * @return float|int $price
+ * @return float
*/
protected function formatPrice($price)
{
@@ -817,28 +803,18 @@ protected function formatPrice($price)
}
/**
- * Get Product price with contextual taxes
+ * Get product price
+ *
+ * @param $product
+ * @param $price
+ * @param $withTax
+ * @return float
*/
-
protected function getProductTaxPrice($product, $price, $withTax = true)
{
- $store = $this->getStoreFromContext();
- return $this->taxHelper->getTaxPrice($product, $price, $withTax, null, null, null, $store, null, true);
+ return $this->taxHelper->getTaxPrice($product, $price, $withTax, null, null, null, $this->contextHelper->getStore($this->scopeId), null, true);
}
- /**
- * Format Image Path Valid
- * @param string $imagePath
- * @return string $imagePath
- */
- protected function fixImagePath($imagePath)
- {
- if (strpos($imagePath, 'catalog/product/') > -1) {
- return $imagePath;
- } else {
- return str_replace('catalog/product', 'catalog/product/', $imagePath);
- }
- }
/**
* Get Product stock from interface
@@ -887,20 +863,26 @@ protected function getSaleableStockBySku($sku)
}
}
} catch (Exception $e) {
+ $this->clerkLogger->error('getSaleableStockBySku Error', ['error' => $e->getMessage()]);
}
return $stockQuantity;
}
/**
- * Get default product fields
+ * Get default fields to build for resourceItem
*
- * @return array
+ * @param string $scope
+ * @param int|string $scopeid
+ * @return array|void
*/
protected function getDefaultFields($scope, $scopeid)
{
try {
+ $this->scope = $scope;
+ $this->scopeId = $scopeid;
+
$fields = [
'name',
'description',
@@ -926,25 +908,19 @@ protected function getDefaultFields($scope, $scopeid)
'tax_rate'
];
- $additionalFields = $this->scopeConfig->getValue(Config::XML_PATH_PRODUCT_SYNCHRONIZATION_ADDITIONAL_FIELDS, $scope, $scopeid);
-
- if ($additionalFields) {
- $fields = array_merge($fields, str_replace(' ', '', explode(',', $additionalFields)));
+ $additional_fields =
+ $this->scopeConfig->getValue(
+ Config::XML_PATH_PRODUCT_SYNCHRONIZATION_ADDITIONAL_FIELDS,
+ $scope,
+ $scopeid
+ );
+ if ($additional_fields) {
+ $fields = array_map('trim', explode(',', $additional_fields));
}
-
- foreach ($fields as $key => $field) {
-
- $fields[$key] = $field;
-
- }
-
- return $fields;
+ return array_values(array_unique($fields));
} catch (Exception $e) {
-
- $this->clerk_logger->error('Getting Default Fields Error', ['error' => $e->getMessage()]);
-
+ $this->clerkLogger->error('Getting Default Fields Error', ['error' => $e->getMessage()]);
}
}
}
-
diff --git a/Model/Api.php b/Model/Api.php
index 1b61399..8ac9913 100644
--- a/Model/Api.php
+++ b/Model/Api.php
@@ -2,72 +2,90 @@
namespace Clerk\Clerk\Model;
+use Clerk\Clerk\Controller\Logger\ClerkLogger;
+use Clerk\Clerk\Helper\Context as ContextHelper;
+use Exception;
use Magento\Framework\App\Config\ScopeConfigInterface;
+use Magento\Framework\App\RequestInterface;
+use Magento\Framework\HTTP\Client\Curl;
use Psr\Log\LoggerInterface;
-use Clerk\Clerk\Controller\Logger\ClerkLogger;
-use Magento\Store\Model\ScopeInterface;
class Api
{
+ /**
+ * @var Curl
+ */
+ public $curlClient;
/**
* @var LoggerInterface
*/
- protected $clerk_logger;
-
+ protected $clerkLogger;
/**
* @var LoggerInterface
*/
protected $logger;
-
/**
* @var ScopeConfigInterface
*/
protected $scopeConfig;
-
/**
* @var string
*/
protected $baseurl = 'https://api.clerk.io/v2/';
-
/**
* @var RequestInterface
*/
protected $requestInterface;
+ /**
+ * @var ContextHelper
+ */
+ protected $contextHelper;
/**
* Api constructor
*
+ * @param LoggerInterface $logger
* @param ScopeConfigInterface $scopeConfig
- * @param \Magento\Framework\App\RequestInterface $requestInterface
+ * @param ClerkLogger $clerkLogger
+ * @param RequestInterface $requestInterface
+ * @param ContextHelper $contextHelper
+ * @param Curl $curl
*/
public function __construct(
- LoggerInterface $logger,
+ LoggerInterface $logger,
ScopeConfigInterface $scopeConfig,
- ClerkLogger $Clerklogger,
- \Magento\Framework\App\RequestInterface $requestInterface
+ ClerkLogger $clerkLogger,
+ RequestInterface $requestInterface,
+ ContextHelper $contextHelper,
+ Curl $curl
) {
- $this->clerk_logger = $Clerklogger;
+ $this->clerkLogger = $clerkLogger;
$this->logger = $logger;
$this->scopeConfig = $scopeConfig;
$this->requestInterface = $requestInterface;
+ $this->contextHelper = $contextHelper;
+ $this->curlClient = $curl;
}
/**
* Add product
+ *
+ * @param array|object $product_data
+ * @param int|string $store_id
+ * @return void
*/
- public function addProduct($params, $store_id = null)
+ public function addProduct($product_data, $store_id = null)
{
try {
$params = [
- 'products' => [$params],
+ 'products' => [$product_data],
];
-
$this->post('product/add', $params, $store_id);
- $this->clerk_logger->log('Added Product', ['response' => $params]);
+ $this->clerkLogger->log('Added Product', ['response' => $product_data]);
- } catch (\Exception $e) {
+ } catch (Exception $e) {
- $this->clerk_logger->error('Adding Products Error', ['error' => $e->getMessage()]);
+ $this->clerkLogger->error('Adding Products Error', ['error' => $e->getMessage()]);
}
}
@@ -77,41 +95,33 @@ public function addProduct($params, $store_id = null)
*
* @param string $endpoint
* @param array $params
- * @throws \Exception
+ * @param string|void $store_id
+ * @return string|void
+ * @throws Exception
*/
private function post($endpoint, $params = [], $store_id = null)
{
try {
-
$params = array_merge($this->getDefaultParams($store_id), $params);
-
$url = $this->baseurl . $endpoint;
-
- $response = $this->_curl_post($url, $params);
-
- return $response;
-
- } catch (\Exception $e) {
-
- $this->clerk_logger->error('POST Request Error', ['error' => $e->getMessage()]);
-
+ $this->curlClient->post($url, $params);
+ return $this->curlClient->getBody();
+ } catch (Exception $e) {
+ $this->clerkLogger->error('POST Request Error', ['error' => $e->getMessage()]);
}
}
+ /**
+ * Get default request params
+ *
+ * @param string|int|void $store_id
+ * @return array
+ */
private function getDefaultParams($store_id = null)
{
if (null === $store_id) {
- $_params = $this->requestInterface->getParams();
- $scope_id = '0';
- $scope = 'default';
- if (array_key_exists('website', $_params)) {
- $scope = 'website';
- $scope_id = $_params[$scope];
- }
- if (array_key_exists('store', $_params)) {
- $scope = 'store';
- $scope_id = $_params[$scope];
- }
+ $scope = $this->contextHelper->getScope();
+ $scope_id = $this->contextHelper->getScopeId();
} else {
$scope = 'store';
$scope_id = $store_id;
@@ -124,229 +134,186 @@ private function getDefaultParams($store_id = null)
}
/**
- * Remove product
+ * Log basket
*
- * @param $productId
- * @throws \Exception
+ * @param array $product_ids
+ * @param string $email
+ * @param int|string|void $store_id
+ * @throws Exception
*/
- public function removeProduct($productId, $store_id = null)
+ public function logBasket($product_ids, $email, $store_id = null)
{
try {
-
$params = [
- 'products' => [$productId],
+ 'products' => $product_ids,
+ 'email' => $email,
];
-
- $this->get('product/remove', $params, $store_id);
- $this->clerk_logger->log('Removed Product', ['response' => $params]);
-
- } catch (\Exception $e) {
-
- $this->clerk_logger->error('Removing Products Error', ['error' => $e->getMessage()]);
-
+ $this->get('log/basket/set', $params, $store_id);
+ $this->clerkLogger->log('Removed Product', ['response' => $params]);
+ } catch (Exception $e) {
+ $this->clerkLogger->error('Removing Products Error', ['error' => $e->getMessage()]);
}
}
-
/**
- * @param $orderIncrementId
- * @param $product_id
- * @param $quantity
- * @return void
+ * Perform a GET request
+ *
+ * @param string $endpoint
+ * @param array $params
+ * @param int|string $store_id
+ * @return string|void
+ * @throws Exception
*/
- public function returnProduct($orderIncrementId, $product_id, $quantity, $store_id)
- {
- try {
- $params = [
- 'product' => (string) $product_id,
- 'order' => (string) $orderIncrementId,
- 'quantity' => (int) $quantity
- ];
- $this->get('log/returned', $params, $store_id);
- $this->clerk_logger->log('Returned Product', ['response' => $params]);
- } catch (\Exception $e) {
- $this->clerk_logger->error('Returning Products Error', ['error' => $e->getMessage()]);
- }
-
- }
- private function _curl_get($url, $params = [])
+ private function get($endpoint, $params = [], $store_id = null)
{
try {
+ $params = array_merge($this->getDefaultParams($store_id), $params);
+ $url = $this->baseurl . $endpoint;
if (!empty($params)) {
- $params = is_array($params) ? http_build_query($params) : $params;
+ $params = http_build_query($params);
$url = $url . '?' . $params;
}
- $curl = curl_init($url);
- curl_setopt($curl, CURLOPT_RETURNTRANSFER, true);
- $response = curl_exec($curl);
- curl_close($curl);
- return $response;
-
- } catch (\Exception $e) {
-
- $this->clerk_logger->error('GET Request Error', ['error' => $e->getMessage()]);
+ $this->curlClient->get($url);
+ return $this->curlClient->getBody();
+ } catch (Exception $e) {
+ $this->clerkLogger->error('GET Request Error', ['error' => $e->getMessage()]);
}
}
- private function _curl_post($url, $params = [])
+ /**
+ * Remove product
+ *
+ * @param int|string $product_id
+ * @param int|string|void $store_id
+ * @throws Exception
+ */
+ public function removeProduct($product_id, $store_id = null)
{
try {
-
- $curl = curl_init($url);
- curl_setopt($curl, CURLOPT_POST, true);
- if (!empty($params)) {
- curl_setopt($curl, CURLOPT_POSTFIELDS, json_encode($params, true));
- }
- curl_setopt($curl, CURLOPT_RETURNTRANSFER, true);
- $response = curl_exec($curl);
- curl_close($curl);
- return $response;
-
- } catch (\Exception $e) {
-
- $this->clerk_logger->error('POST Request Error', ['error' => $e->getMessage()]);
-
+ $params = [
+ 'products' => [$product_id],
+ ];
+ $this->get('product/remove', $params, $store_id);
+ $this->clerkLogger->log('Removed Product', ['response' => $params]);
+ } catch (Exception $e) {
+ $this->clerkLogger->error('Removing Products Error', ['error' => $e->getMessage()]);
}
}
/**
- * Perform a GET request
+ * Return product api caller
*
- * @param string $endpoint
- * @param array $params
- * @throws \Exception
+ * @param int|string $orderIncrementId
+ * @param int|string $product_id
+ * @param int $quantity
+ * @param int|string $store_id
+ * @return void
*/
- private function get($endpoint, $params = [], $store_id = null)
+ public function returnProduct($orderIncrementId, $product_id, $quantity, $store_id)
{
try {
-
- $params = array_merge($this->getDefaultParams($store_id), $params);
-
- $url = $this->baseurl . $endpoint;
-
- $response = $this->_curl_get($url, $params);
-
- return $response;
-
- } catch (\Exception $e) {
-
- $this->clerk_logger->error('GET Request Error', ['error' => $e->getMessage()]);
-
+ $params = [
+ 'product' => (string) $product_id,
+ 'order' => (string) $orderIncrementId,
+ 'quantity' => (int) $quantity
+ ];
+ $this->get('log/returned', $params, $store_id);
+ $this->clerkLogger->log('Returned Product', ['response' => $params]);
+ } catch (Exception $e) {
+ $this->clerkLogger->error('Returning Products Error', ['error' => $e->getMessage()]);
}
}
/**
* Validate public & private key
*
- * @param $publicKey
- * @param $privateKey
- * @return string
- * @throws \Exception
+ * @param string $publicKey
+ * @param string $privateKey
+ * @return string|void
+ * @throws Exception
*/
public function keysValid($publicKey, $privateKey)
{
try {
-
$params = [
'key' => $publicKey,
'private_key' => $privateKey,
];
-
return $this->get('client/account/info', $params);
-
- } catch (\Exception $e) {
-
- $this->clerk_logger->error('Key Validation Error', ['error' => $e->getMessage()]);
-
+ } catch (Exception $e) {
+ $this->clerkLogger->error('Key Validation Error', ['error' => $e->getMessage()]);
}
}
/**
* Get available facet attributes
*
- * @throws \Exception
+ * @return array|object|void
+ * @throws Exception
*/
public function getFacetAttributes()
{
try {
-
$facetAttributesResponse = $this->get('product/facets');
if ($facetAttributesResponse) {
return json_decode($facetAttributesResponse);
}
-
- } catch (\Exception $e) {
-
- $this->clerk_logger->error('Getting Facet Attributes Error', ['error' => $e->getMessage()]);
-
+ } catch (Exception $e) {
+ $this->clerkLogger->error('Getting Facet Attributes Error', ['error' => $e->getMessage()]);
}
}
+ /**
+ * Get endpoint for embedded content
+ *
+ * @param string $contentId
+ * @return void|array|object
+ */
public function getEndpointForContent($contentId)
{
try {
-
$contentResult = json_decode($this->getContent());
-
if ($contentResult) {
-
foreach ($contentResult->contents as $content) {
-
if ($content->type !== 'html') {
-
continue;
-
}
-
if ($content->id === $contentId) {
-
return $content->api;
-
}
}
}
-
- } catch (\Exception $e) {
-
- $this->clerk_logger->error('Getting Endpoint For Content Error', ['error' => $e->getMessage()]);
-
+ } catch (Exception $e) {
+ $this->clerkLogger->error('Getting Endpoint For Content Error', ['error' => $e->getMessage()]);
}
}
/**
* Get Clerk Content
*
- * @param int $storeId
- * @return string
- * @throws \Exception
+ * @param int $store_id
+ * @return string|void
+ * @throws Exception
*/
- public function getContent($storeId = null)
+ public function getContent($store_id = null)
{
try {
- $_params = $this->requestInterface->getParams();
- $scope_id = '0';
- $scope = 'default';
- if (array_key_exists('website', $_params)) {
- $scope = 'website';
- $scope_id = $_params[$scope];
- }
- if (array_key_exists('store', $_params)) {
+ if (null === $store_id) {
+ $scope = $this->contextHelper->getScope();
+ $scope_id = $this->contextHelper->getScopeId();
+ } else {
$scope = 'store';
- $scope_id = $_params[$scope];
+ $scope_id = $store_id;
}
$params = [
'key' => $this->scopeConfig->getValue(Config::XML_PATH_PUBLIC_KEY, $scope, $scope_id),
'private_key' => $this->scopeConfig->getValue(Config::XML_PATH_PRIVATE_KEY, $scope, $scope_id),
];
-
return $this->get('client/account/content/list', $params);
-
- } catch (\Exception $e) {
-
- $this->clerk_logger->error('Getting Content Error', ['error' => $e->getMessage()]);
-
+ } catch (Exception $e) {
+ $this->clerkLogger->error('Getting Content Error', ['error' => $e->getMessage()]);
}
}
@@ -355,8 +322,8 @@ public function getContent($storeId = null)
*
* @param string $token_string
* @param string $publicKey
- * @throws \Exception
- * @return array
+ * @throws Exception
+ * @return array|void|bool
*/
public function verifyToken($token_string = null, $publicKey = null)
{
@@ -365,28 +332,30 @@ public function verifyToken($token_string = null, $publicKey = null)
}
try {
- $query_params = array(
+ $query_params = [
'token' => $token_string,
'key' => $publicKey,
- );
-
+ ];
$url = $this->baseurl . 'token/verify';
- $response = $this->_curl_get($url, $query_params);
-
+ $response = $this->get($url, $query_params);
$decodedResponse = json_decode($response, true);
-
return (array) $decodedResponse;
-
- } catch (\Exception $e) {
+ } catch (Exception $e) {
$this->logger->error(' Communicator "postTokenVerification"', ['error' => $e->getMessage()]);
}
}
+ /**
+ * Get mandatory parameters for endpoint
+ *
+ * @param string $endpoint
+ * @return string[]
+ */
public function getParametersForEndpoint($endpoint)
{
- $endpointMap = [
+ $endpoint_map = [
'search/search' => [
'query',
'limit'
@@ -457,7 +426,6 @@ public function getParametersForEndpoint($endpoint)
'limit',
'category'
],
-
'recommendations/visitor/history' => [
'limit',
],
@@ -481,13 +449,10 @@ public function getParametersForEndpoint($endpoint)
],
];
- if (array_key_exists($endpoint, $endpointMap)) {
- return $endpointMap[$endpoint];
+ if (array_key_exists($endpoint, $endpoint_map)) {
+ return $endpoint_map[$endpoint];
}
return ['limit'];
}
-
-
-
}
diff --git a/Model/Config.php b/Model/Config.php
index be058b5..1cb1fef 100644
--- a/Model/Config.php
+++ b/Model/Config.php
@@ -7,108 +7,111 @@ class Config
/**
* General configuration
*/
- const XML_PATH_PRIVATE_KEY = 'clerk/general/private_key';
- const XML_PATH_PUBLIC_KEY = 'clerk/general/public_key';
- const XML_PATH_LANGUAGE = 'clerk/general/language';
- const XML_PATH_INCLUDE_PAGES = 'clerk/general/include_pages';
- const XML_PATH_USE_LEGACY_AUTH = 'clerk/general/legacy_auth';
- const XML_PATH_PAGES_ADDITIONAL_FIELDS = 'clerk/general/pages_additional_fields';
-
+ public const XML_PATH_PRIVATE_KEY = 'clerk/general/private_key';
+ public const XML_PATH_PUBLIC_KEY = 'clerk/general/public_key';
+ public const XML_PATH_LANGUAGE = 'clerk/general/language';
+ public const XML_PATH_INCLUDE_PAGES = 'clerk/general/include_pages';
+ public const XML_PATH_USE_LEGACY_AUTH = 'clerk/general/legacy_auth';
+ public const XML_PATH_PAGES_ADDITIONAL_FIELDS = 'clerk/general/pages_additional_fields';
/**
* Product Synchronization configuration
*/
- const XML_PATH_PRODUCT_SYNCHRONIZATION_REAL_TIME_ENABLED = 'clerk/product_synchronization/use_realtime_updates';
- const XML_PATH_PRODUCT_SYNCHRONIZATION_COLLECT_EMAILS = 'clerk/product_synchronization/collect_emails';
- const XML_PATH_PRODUCT_SYNCHRONIZATION_COLLECT_BASKETS = 'clerk/product_synchronization/collect_baskets';
- const XML_PATH_PRODUCT_SYNCHRONIZATION_ADDITIONAL_FIELDS = 'clerk/product_synchronization/additional_fields';
- const XML_PATH_PRODUCT_SYNCHRONIZATION_ADDITIONAL_FIELDS_HEAVY_QUERY = 'clerk/product_synchronization/additional_fields_heavy_query';
- const XML_PATH_PRODUCT_SYNCHRONIZATION_SALABLE_ONLY = 'clerk/product_synchronization/saleable_only';
- const XML_PATH_PRODUCT_SYNCHRONIZATION_VISIBILITY = 'clerk/product_synchronization/visibility';
- const XML_PATH_PRODUCT_SYNCHRONIZATION_DISABLE_ORDER_SYNCHRONIZATION = 'clerk/product_synchronization/disable_order_synchronization';
- const XML_PATH_PRODUCT_SYNCHRONIZATION_IMAGE_TYPE = 'clerk/product_synchronization/image_type';
- const XML_PATH_PRODUCT_SYNCHRONIZATION_ENABLE_ORDER_RETURN_SYNCHRONIZATION = 'clerk/product_synchronization/return_order_synchronization';
+ public const XML_PATH_PRODUCT_SYNCHRONIZATION_REAL_TIME_ENABLED =
+ 'clerk/product_synchronization/use_realtime_updates';
+ public const XML_PATH_PRODUCT_SYNCHRONIZATION_COLLECT_EMAILS = 'clerk/product_synchronization/collect_emails';
+ public const XML_PATH_PRODUCT_SYNCHRONIZATION_COLLECT_BASKETS = 'clerk/product_synchronization/collect_baskets';
+ public const XML_PATH_PRODUCT_SYNCHRONIZATION_ADDITIONAL_FIELDS = 'clerk/product_synchronization/additional_fields';
+ public const XML_PATH_PRODUCT_SYNCHRONIZATION_ADDITIONAL_FIELDS_HEAVY_QUERY =
+ 'clerk/product_synchronization/additional_fields_heavy_query';
+ public const XML_PATH_PRODUCT_SYNCHRONIZATION_SALABLE_ONLY = 'clerk/product_synchronization/saleable_only';
+ public const XML_PATH_PRODUCT_SYNCHRONIZATION_VISIBILITY = 'clerk/product_synchronization/visibility';
+ public const XML_PATH_PRODUCT_SYNCHRONIZATION_DISABLE_ORDER_SYNCHRONIZATION =
+ 'clerk/product_synchronization/disable_order_synchronization';
+ public const XML_PATH_PRODUCT_SYNCHRONIZATION_IMAGE_TYPE = 'clerk/product_synchronization/image_type';
+ public const XML_PATH_PRODUCT_SYNCHRONIZATION_ENABLE_ORDER_RETURN_SYNCHRONIZATION =
+ 'clerk/product_synchronization/return_order_synchronization';
/**
* Customer Synchronization configuration
*/
- const XML_PATH_CUSTOMER_SYNCHRONIZATION_ENABLED = 'clerk/customer_synchronization/enabled';
- const XML_PATH_CUSTOMER_SYNCHRONIZATION_EXTRA_ATTRIBUTES = 'clerk/customer_synchronization/extra_attributes';
- const XML_PATH_SUBSCRIBER_SYNCHRONIZATION_ENABLED = 'clerk/customer_synchronization/sync_subscribers';
+ public const XML_PATH_CUSTOMER_SYNCHRONIZATION_ENABLED = 'clerk/customer_synchronization/enabled';
+ public const XML_PATH_CUSTOMER_SYNCHRONIZATION_EXTRA_ATTRIBUTES = 'clerk/customer_synchronization/extra_attributes';
+ public const XML_PATH_SUBSCRIBER_SYNCHRONIZATION_ENABLED = 'clerk/customer_synchronization/sync_subscribers';
/**
* Search configuration
*/
- const XML_PATH_SEARCH_ENABLED = 'clerk/search/enabled';
- const XML_PATH_SEARCH_INCLUDE_CATEGORIES = 'clerk/search/include_categories';
- const XML_PATH_SEARCH_CATEGORIES = 'clerk/search/categories';
- const XML_PATH_SEARCH_SUGGESTIONS = 'clerk/search/suggestions';
- const XML_PATH_SEARCH_PAGES = 'clerk/search/pages';
- const XML_PATH_SEARCH_PAGES_TYPE = 'clerk/search/pages_type';
- const XML_PATH_SEARCH_TEMPLATE = 'clerk/search/template';
- const XML_PATH_SEARCH_NO_RESULTS_TEXT = 'clerk/search/no_results_text';
- const XML_PATH_SEARCH_LOAD_MORE_TEXT = 'clerk/search/load_more_text';
+ public const XML_PATH_SEARCH_ENABLED = 'clerk/search/enabled';
+ public const XML_PATH_SEARCH_INCLUDE_CATEGORIES = 'clerk/search/include_categories';
+ public const XML_PATH_SEARCH_CATEGORIES = 'clerk/search/categories';
+ public const XML_PATH_SEARCH_SUGGESTIONS = 'clerk/search/suggestions';
+ public const XML_PATH_SEARCH_PAGES = 'clerk/search/pages';
+ public const XML_PATH_SEARCH_PAGES_TYPE = 'clerk/search/pages_type';
+ public const XML_PATH_SEARCH_TEMPLATE = 'clerk/search/template';
+ public const XML_PATH_SEARCH_NO_RESULTS_TEXT = 'clerk/search/no_results_text';
+ public const XML_PATH_SEARCH_LOAD_MORE_TEXT = 'clerk/search/load_more_text';
/**
* Faceted Search configuration
*/
- const XML_PATH_FACETED_SEARCH_ENABLED = 'clerk/faceted_search/enabled';
- const XML_PATH_FACETED_SEARCH_DESIGN = 'clerk/faceted_search/design';
- const XML_PATH_FACETED_SEARCH_ATTRIBUTES = 'clerk/faceted_search/attributes';
- const XML_PATH_FACETED_SEARCH_MULTISELECT_ATTRIBUTES = 'clerk/faceted_search/multiselect_attributes';
- const XML_PATH_FACETED_SEARCH_TITLES = 'clerk/faceted_search/titles';
+ public const XML_PATH_FACETED_SEARCH_ENABLED = 'clerk/faceted_search/enabled';
+ public const XML_PATH_FACETED_SEARCH_DESIGN = 'clerk/faceted_search/design';
+ public const XML_PATH_FACETED_SEARCH_ATTRIBUTES = 'clerk/faceted_search/attributes';
+ public const XML_PATH_FACETED_SEARCH_MULTISELECT_ATTRIBUTES = 'clerk/faceted_search/multiselect_attributes';
+ public const XML_PATH_FACETED_SEARCH_TITLES = 'clerk/faceted_search/titles';
/**
* Live search configuration
*/
- const XML_PATH_LIVESEARCH_ENABLED = 'clerk/livesearch/enabled';
- const XML_PATH_LIVESEARCH_INCLUDE_CATEGORIES = 'clerk/livesearch/include_categories';
- const XML_PATH_LIVESEARCH_CATEGORIES = 'clerk/livesearch/categories';
- const XML_PATH_LIVESEARCH_SUGGESTIONS = 'clerk/livesearch/suggestions';
- const XML_PATH_LIVESEARCH_PAGES = 'clerk/livesearch/pages';
- const XML_PATH_LIVESEARCH_PAGES_TYPE = 'clerk/livesearch/pages_type';
- const XML_PATH_LIVESEARCH_DROPDOWN_POSITION = 'clerk/livesearch/dropdown_position';
- const XML_PATH_LIVESEARCH_TEMPLATE = 'clerk/livesearch/template';
- const XML_PATH_LIVESEARCH_INPUT_SELECTOR = 'clerk/livesearch/input_selector';
- const XML_PATH_LIVESEARCH_FORM_SELECTOR = 'clerk/livesearch/form_selector';
+ public const XML_PATH_LIVESEARCH_ENABLED = 'clerk/livesearch/enabled';
+ public const XML_PATH_LIVESEARCH_INCLUDE_CATEGORIES = 'clerk/livesearch/include_categories';
+ public const XML_PATH_LIVESEARCH_CATEGORIES = 'clerk/livesearch/categories';
+ public const XML_PATH_LIVESEARCH_SUGGESTIONS = 'clerk/livesearch/suggestions';
+ public const XML_PATH_LIVESEARCH_PAGES = 'clerk/livesearch/pages';
+ public const XML_PATH_LIVESEARCH_PAGES_TYPE = 'clerk/livesearch/pages_type';
+ public const XML_PATH_LIVESEARCH_DROPDOWN_POSITION = 'clerk/livesearch/dropdown_position';
+ public const XML_PATH_LIVESEARCH_TEMPLATE = 'clerk/livesearch/template';
+ public const XML_PATH_LIVESEARCH_INPUT_SELECTOR = 'clerk/livesearch/input_selector';
+ public const XML_PATH_LIVESEARCH_FORM_SELECTOR = 'clerk/livesearch/form_selector';
/**
* Powerstep configuration
*/
- const XML_PATH_POWERSTEP_ENABLED = 'clerk/powerstep/enabled';
- const XML_PATH_POWERSTEP_TYPE = 'clerk/powerstep/type';
- const XML_PATH_POWERSTEP_TEMPLATES = 'clerk/powerstep/templates';
- const XML_PATH_POWERSTEP_FILTER_DUPLICATES = 'clerk/powerstep/powerstep_filter';
+ public const XML_PATH_POWERSTEP_ENABLED = 'clerk/powerstep/enabled';
+ public const XML_PATH_POWERSTEP_TYPE = 'clerk/powerstep/type';
+ public const XML_PATH_POWERSTEP_TEMPLATES = 'clerk/powerstep/templates';
+ public const XML_PATH_POWERSTEP_FILTER_DUPLICATES = 'clerk/powerstep/powerstep_filter';
/**
* Exit intent configuration
*/
- const XML_PATH_EXIT_INTENT_ENABLED = 'clerk/exit_intent/enabled';
- const XML_PATH_EXIT_INTENT_TEMPLATE = 'clerk/exit_intent/template';
+ public const XML_PATH_EXIT_INTENT_ENABLED = 'clerk/exit_intent/enabled';
+ public const XML_PATH_EXIT_INTENT_TEMPLATE = 'clerk/exit_intent/template';
/**
* Category configuration
*/
- const XML_PATH_CATEGORY_ENABLED = 'clerk/category/enabled';
- const XML_PATH_CATEGORY_CONTENT = 'clerk/category/content';
- const XML_PATH_CATEGORY_FILTER_DUPLICATES = 'clerk/category/category_filter';
+ public const XML_PATH_CATEGORY_ENABLED = 'clerk/category/enabled';
+ public const XML_PATH_CATEGORY_CONTENT = 'clerk/category/content';
+ public const XML_PATH_CATEGORY_FILTER_DUPLICATES = 'clerk/category/category_filter';
/**
* Product configuration
*/
- const XML_PATH_PRODUCT_ENABLED = 'clerk/product/enabled';
- const XML_PATH_PRODUCT_CONTENT = 'clerk/product/content';
- const XML_PATH_PRODUCT_FILTER_DUPLICATES = 'clerk/product/product_filter';
+ public const XML_PATH_PRODUCT_ENABLED = 'clerk/product/enabled';
+ public const XML_PATH_PRODUCT_CONTENT = 'clerk/product/content';
+ public const XML_PATH_PRODUCT_FILTER_DUPLICATES = 'clerk/product/product_filter';
/**
* Cart configuration
*/
- const XML_PATH_CART_ENABLED = 'clerk/cart/enabled';
- const XML_PATH_CART_CONTENT = 'clerk/cart/content';
- const XML_PATH_CART_FILTER_DUPLICATES = 'clerk/cart/cart_filter';
+ public const XML_PATH_CART_ENABLED = 'clerk/cart/enabled';
+ public const XML_PATH_CART_CONTENT = 'clerk/cart/content';
+ public const XML_PATH_CART_FILTER_DUPLICATES = 'clerk/cart/cart_filter';
/**
* Logger configuration
*/
- const XML_PATH_LOG_LEVEL = 'clerk/log/level';
- const XML_PATH_LOG_TO = 'clerk/log/to';
- const XML_PATH_LOG_ENABLED = 'clerk/log/enabled';
+ public const XML_PATH_LOG_LEVEL = 'clerk/log/level';
+ public const XML_PATH_LOG_TO = 'clerk/log/to';
+ public const XML_PATH_LOG_ENABLED = 'clerk/log/enabled';
}
diff --git a/Model/Config/Backend/FacetTitles.php b/Model/Config/Backend/FacetTitles.php
index f46c542..5e0d2f6 100644
--- a/Model/Config/Backend/FacetTitles.php
+++ b/Model/Config/Backend/FacetTitles.php
@@ -2,17 +2,18 @@
namespace Clerk\Clerk\Model\Config\Backend;
-class FacetTitles extends \Magento\Framework\App\Config\Value
+use Magento\Framework\App\Config\Value;
+
+class FacetTitles extends Value
{
/**
* JSON Encode value
*
- * @return $this|void
+ * @return $this
*/
public function beforeSave()
{
$this->setValue(json_encode(array_filter((array) $this->getValue())));
-
return $this;
}
}
diff --git a/Model/Config/Source/Content.php b/Model/Config/Source/Content.php
index cb3bab6..20e6257 100644
--- a/Model/Config/Source/Content.php
+++ b/Model/Config/Source/Content.php
@@ -3,14 +3,19 @@
namespace Clerk\Clerk\Model\Config\Source;
use Clerk\Clerk\Model\Api;
+use Exception;
+use Magento\Framework\Option\ArrayInterface;
-class Content implements \Magento\Framework\Option\ArrayInterface
+class Content implements ArrayInterface
{
/**
* @var Api
*/
protected $api;
+ /**
+ * @param Api $api
+ */
public function __construct(Api $api)
{
$this->api = $api;
@@ -42,7 +47,7 @@ public function toOptionArray()
];
}
}
- } catch (\Exception $e) {
+ } catch (Exception $e) {
$contents[] = [
'value' => '',
'label' => 'No content found'
diff --git a/Model/Config/Source/DropDownPosition.php b/Model/Config/Source/DropDownPosition.php
index c12f1ac..fae8412 100644
--- a/Model/Config/Source/DropDownPosition.php
+++ b/Model/Config/Source/DropDownPosition.php
@@ -14,14 +14,12 @@ class DropDownPosition implements ArrayInterface
*/
public function toOptionArray()
{
- $Positions= [
+ return [
['value' => 'left', 'label' => 'Left'],
['value' => 'center', 'label' => 'Center'],
['value' => 'right', 'label' => 'Right'],
['value' => 'below', 'label' => 'Below'],
['value' => 'off', 'label' => 'Off']
];
-
- return $Positions;
}
}
diff --git a/Model/Config/Source/FacetAttributes.php b/Model/Config/Source/FacetAttributes.php
index ca55bab..c0fb09f 100644
--- a/Model/Config/Source/FacetAttributes.php
+++ b/Model/Config/Source/FacetAttributes.php
@@ -3,6 +3,7 @@
namespace Clerk\Clerk\Model\Config\Source;
use Clerk\Clerk\Model\Api;
+use Exception;
use Magento\Framework\Option\ArrayInterface;
class FacetAttributes implements ArrayInterface
@@ -31,11 +32,15 @@ public function toOptionArray()
{
$res = [];
- foreach (self::toArray() as $index => $value) {
- $res[] = [
- 'value' => $value,
- 'label' => $value
- ];
+ try {
+ foreach (self::toArray() as $_ => $value) {
+ $res[] = [
+ 'value' => $value,
+ 'label' => $value
+ ];
+ }
+ } catch (Exception $e) {
+ return $res;
}
return $res;
@@ -45,16 +50,15 @@ public function toOptionArray()
* Get options in "key-value" format
*
* @return array
+ * @throws Exception
*/
public function toArray()
{
$attributes = $this->getFacetAttributes();
$values = [];
-
foreach ($attributes as $attribute => $facet) {
$values[$attribute] = $attribute;
}
-
return $values;
}
@@ -62,15 +66,14 @@ public function toArray()
* Get facet attributes from Clerk API
*
* @return array|mixed
+ * @throws Exception
*/
private function getFacetAttributes()
{
$attributes = $this->api->getFacetAttributes();
-
if ($attributes && isset($attributes->facets)) {
return $attributes->facets;
}
-
return [];
}
}
diff --git a/Model/Config/Source/ImageType.php b/Model/Config/Source/ImageType.php
index 53e3605..d57ad25 100644
--- a/Model/Config/Source/ImageType.php
+++ b/Model/Config/Source/ImageType.php
@@ -2,6 +2,7 @@
namespace Clerk\Clerk\Model\Config\Source;
+use Exception;
use Magento\Catalog\Helper\Image;
use Magento\Framework\Option\ArrayInterface;
use Magento\Framework\View\ConfigInterface;
@@ -20,6 +21,10 @@ class ImageType implements ArrayInterface
protected $themeCollectionFactory;
+ /**
+ * @param ConfigInterface $viewConfig
+ * @param CollectionFactory $themeCollectionFactory
+ */
public function __construct(
ConfigInterface $viewConfig,
CollectionFactory $themeCollectionFactory
@@ -37,17 +42,13 @@ public function toOptionArray()
{
$types = [];
- /** @var Collection $themes */
$themes = $this->themeCollectionFactory->create();
$themes->addAreaFilter('frontend');
$common = [];
- /** @var ThemeInterface $theme */
foreach ($themes as $theme) {
-
try {
-
$config = $this->viewConfig->getViewConfig([
'themeModel' => $theme,
]);
@@ -55,11 +56,8 @@ public function toOptionArray()
$types[$theme->getCode()] = $mediaEntities;
$common = $common ? array_intersect_key($common, $types[$theme->getCode()]) : $types[$theme->getCode()];
-
- } catch (\Exception $e) {
-
+ } catch (Exception $e) {
continue;
-
}
}
diff --git a/Model/Config/Source/Language.php b/Model/Config/Source/Language.php
index db7c408..127905b 100644
--- a/Model/Config/Source/Language.php
+++ b/Model/Config/Source/Language.php
@@ -2,8 +2,8 @@
namespace Clerk\Clerk\Model\Config\Source;
-use Magento\Framework\Option\ArrayInterface;
use Magento\Framework\Locale\Resolver;
+use Magento\Framework\Option\ArrayInterface;
class Language implements ArrayInterface
{
@@ -19,8 +19,7 @@ class Language implements ArrayInterface
*/
public function __construct(
Resolver $localeResolver
- )
- {
+ ) {
$this->_store = $localeResolver;
}
@@ -34,7 +33,7 @@ public function toOptionArray()
$store = $this->_store;
- $Langs = [
+ $languages = [
['value' => 'danish', 'label' => 'Danish'],
['value' => 'dutch', 'label' => 'Dutch'],
['value' => 'english', 'label' => 'English'],
@@ -54,7 +53,7 @@ public function toOptionArray()
$locale = $store->getLocale();
- $LangsAuto = [
+ $langs_auto = [
'da_DK' => 'Danish',
'nl_NL' => 'Dutch',
'en_US' => 'English',
@@ -77,18 +76,18 @@ public function toOptionArray()
'tr_TR' => 'Turkish'
];
- if (isset($LangsAuto[$locale])) {
+ if (isset($langs_auto[$locale])) {
- $AutoLang = ['label' => sprintf('Auto (%s)', $LangsAuto[$locale]), 'value' => 'auto_'.strtolower($LangsAuto[$locale])];
+ $auto_lang = ['label' => sprintf('Auto (%s)', $langs_auto[$locale]), 'value' => 'auto_'.strtolower($langs_auto[$locale])];
}
- if (isset($AutoLang)) {
+ if (isset($auto_lang)) {
- array_unshift($Langs, $AutoLang);
+ array_unshift($languages, $auto_lang);
}
- return $Langs;
+ return $languages;
}
}
diff --git a/Model/Config/Source/LoggerLevel.php b/Model/Config/Source/LoggerLevel.php
index 54df8c9..ebfbdbb 100644
--- a/Model/Config/Source/LoggerLevel.php
+++ b/Model/Config/Source/LoggerLevel.php
@@ -7,9 +7,9 @@
class LoggerLevel implements ArrayInterface
{
- const LEVEL_ERROR = 'error';
- const LEVEL_WARN = 'warn';
- const LEVEL_ALL = 'all';
+ public const LEVEL_ERROR = 'error';
+ public const LEVEL_WARN = 'warn';
+ public const LEVEL_ALL = 'all';
/**
* Options getter
*
diff --git a/Model/Config/Source/LoggerTo.php b/Model/Config/Source/LoggerTo.php
index 66d1c91..b9f125e 100644
--- a/Model/Config/Source/LoggerTo.php
+++ b/Model/Config/Source/LoggerTo.php
@@ -6,8 +6,8 @@
class LoggerTo implements ArrayInterface
{
- const TO_FILE = 'file';
- const TO_COLLECTION = 'collect';
+ public const TO_FILE = 'file';
+ public const TO_COLLECTION = 'collect';
/**
* Options getter
*
diff --git a/Model/Config/Source/MultiselectFacetAttributes.php b/Model/Config/Source/MultiselectFacetAttributes.php
index 2dce420..0e4c60b 100644
--- a/Model/Config/Source/MultiselectFacetAttributes.php
+++ b/Model/Config/Source/MultiselectFacetAttributes.php
@@ -2,10 +2,10 @@
namespace Clerk\Clerk\Model\Config\Source;
+use Clerk\Clerk\Helper\Context as ContextHelper;
use Clerk\Clerk\Model\Config;
use Magento\Framework\App\Config\ScopeConfigInterface;
use Magento\Framework\Option\ArrayInterface;
-use Magento\Store\Model\ScopeInterface;
class MultiselectFacetAttributes implements ArrayInterface
{
@@ -13,18 +13,21 @@ class MultiselectFacetAttributes implements ArrayInterface
* @var ScopeConfigInterface
*/
protected $scopeConfig;
-
/**
- * @var RequestInterface
+ * @var ContextHelper
*/
- protected $requestInterface;
+ protected $contextHelper;
+ /**
+ * @param ScopeConfigInterface $scopeConfig
+ * @param ContextHelper $contextHelper
+ */
public function __construct(
ScopeConfigInterface $scopeConfig,
- \Magento\Framework\App\RequestInterface $requestInterface
+ ContextHelper $contextHelper
) {
$this->scopeConfig = $scopeConfig;
- $this->requestInterface = $requestInterface;
+ $this->contextHelper = $contextHelper;
}
/**
@@ -36,7 +39,7 @@ public function toOptionArray()
{
$res = [];
- foreach (self::toArray() as $index => $value) {
+ foreach (self::toArray() as $_ => $value) {
$res[] = ['value' => $value, 'label' => $value];
}
@@ -52,7 +55,7 @@ public function toArray()
{
$attributes = $this->getConfiguredAttributes();
- $attributes_defined = is_null($attributes) ? false : true;
+ $attributes_defined = $attributes !== null;
if (!$attributes_defined) {
return [];
@@ -72,17 +75,8 @@ public function toArray()
*/
private function getConfiguredAttributes()
{
- $_params = $this->requestInterface->getParams();
- $scope_id = '0';
- $scope = 'default';
- if (array_key_exists('website', $_params)) {
- $scope = 'website';
- $scope_id = $_params[$scope];
- }
- if (array_key_exists('store', $_params)) {
- $scope = 'store';
- $scope_id = $_params[$scope];
- }
+ $scope = $this->contextHelper->getScopeAdmin();
+ $scope_id = $this->contextHelper->getScopeIdAdmin();
return $this->scopeConfig->getValue(Config::XML_PATH_FACETED_SEARCH_ATTRIBUTES, $scope, $scope_id);
}
}
diff --git a/Model/Config/Source/Numbers.php b/Model/Config/Source/Numbers.php
index afb5b5b..a553de2 100644
--- a/Model/Config/Source/Numbers.php
+++ b/Model/Config/Source/Numbers.php
@@ -14,7 +14,7 @@ class Numbers implements ArrayInterface
*/
public function toOptionArray()
{
- $Numbers = [
+ return [
['value' => '0', 'label' => 'Don\'t show'],
['value' => '1', 'label' => '1'],
['value' => '2', 'label' => '2'],
@@ -27,7 +27,5 @@ public function toOptionArray()
['value' => '9', 'label' => '9'],
['value' => '10', 'label' => '10']
];
-
- return $Numbers;
}
}
diff --git a/Model/Config/Source/PagesType.php b/Model/Config/Source/PagesType.php
index 255ce53..fc9e598 100644
--- a/Model/Config/Source/PagesType.php
+++ b/Model/Config/Source/PagesType.php
@@ -14,11 +14,9 @@ class PagesType implements ArrayInterface
*/
public function toOptionArray()
{
- $PagesType = [
+ return [
['value' => 'cms page', 'label' => 'CMS Page'],
['value' => 'all', 'label' => 'All']
];
-
- return $PagesType;
}
}
diff --git a/Model/Config/Source/PowerstepType.php b/Model/Config/Source/PowerstepType.php
index 35673e5..1051b2a 100644
--- a/Model/Config/Source/PowerstepType.php
+++ b/Model/Config/Source/PowerstepType.php
@@ -6,8 +6,8 @@
class PowerstepType implements ArrayInterface
{
- const TYPE_PAGE = 1;
- const TYPE_POPUP = 2;
+ public const TYPE_PAGE = 1;
+ public const TYPE_POPUP = 2;
/**
* Options getter
diff --git a/Observer/CheckoutCartAddProductCompleteObserver.php b/Observer/CheckoutCartAddProductCompleteObserver.php
index 6f8593d..61c67bf 100644
--- a/Observer/CheckoutCartAddProductCompleteObserver.php
+++ b/Observer/CheckoutCartAddProductCompleteObserver.php
@@ -2,58 +2,51 @@
namespace Clerk\Clerk\Observer;
+use Clerk\Clerk\Helper\Config as ConfigHelper;
use Clerk\Clerk\Model\Config;
+use Clerk\Clerk\Model\Config\Source\PowerstepType;
use Magento\Checkout\Model\Session;
-use Magento\Framework\App\Config\ScopeConfigInterface;
use Magento\Framework\Event\Observer;
use Magento\Framework\Event\ObserverInterface;
-use Magento\Store\Model\ScopeInterface;
class CheckoutCartAddProductCompleteObserver implements ObserverInterface
{
- /**
- * @var ScopeConfigInterface
- */
- protected $scopeConfig;
-
/**
* @var Session
*/
protected $checkoutSession;
+ /**
+ * @var ConfigHelper
+ */
+ protected $configHelper;
/**
* CheckoutCartAddProductCompleteObserver constructor.
*
- * @param ScopeConfigInterface $scopeConfig
+ * @param ConfigHelper $configHelper
* @param Session $checkoutSession
*/
- public function __construct(ScopeConfigInterface $scopeConfig, Session $checkoutSession)
- {
- $this->scopeConfig = $scopeConfig;
+ public function __construct(
+ ConfigHelper $configHelper,
+ Session $checkoutSession
+ ) {
+ $this->configHelper = $configHelper;
$this->checkoutSession = $checkoutSession;
}
/**
+ * Event observer
+ *
* @param Observer $observer
* @return void
*/
- public function execute(\Magento\Framework\Event\Observer $observer)
+ public function execute(Observer $observer)
{
- if ($this->scopeConfig->getValue(Config::XML_PATH_POWERSTEP_TYPE, ScopeInterface::SCOPE_STORE) == Config\Source\PowerstepType::TYPE_POPUP) {
+ if ($this->configHelper->getValue(Config::XML_PATH_POWERSTEP_TYPE) == PowerstepType::TYPE_POPUP) {
$product = $observer->getProduct();
$this->checkoutSession->setClerkShowPowerstep(true);
$this->checkoutSession->setClerkProductId($product->getId());
}
}
-
- /**
- * Determine if Clerk search is enabled
- *
- * @return bool
- */
-// private function isClerkSearchEnabled()
-// {
-// return $this->scopeConfig->isSetFlag(Config::XML_PATH_SEARCH_ENABLED);
-// }
}
diff --git a/Observer/CheckoutCartUpdateItemsAfterObserver.php b/Observer/CheckoutCartUpdateItemsAfterObserver.php
index f66d917..8e0bf40 100644
--- a/Observer/CheckoutCartUpdateItemsAfterObserver.php
+++ b/Observer/CheckoutCartUpdateItemsAfterObserver.php
@@ -2,27 +2,18 @@
namespace Clerk\Clerk\Observer;
+use Clerk\Clerk\Helper\Config as ConfigHelper;
+use Clerk\Clerk\Helper\Context as ContextHelper;
+use Clerk\Clerk\Model\Api;
use Clerk\Clerk\Model\Config;
-use Magento\Checkout\Model\Session;
-use Magento\Framework\App\Config\ScopeConfigInterface;
-use Magento\Framework\Event\Observer;
-use Magento\Framework\Event\ObserverInterface;
-use Magento\Store\Model\ScopeInterface;
+use Exception;
use Magento\Checkout\Model\Cart;
use Magento\Customer\Model\Session as CustomerSession;
+use Magento\Framework\Event\Observer;
+use Magento\Framework\Event\ObserverInterface;
class CheckoutCartUpdateItemsAfterObserver implements ObserverInterface
{
- /**
- * @var ScopeConfigInterface
- */
- protected $scopeConfig;
-
- /**
- * @var Session
- */
- protected $checkoutSession;
-
/**
* @var CustomerSession
*/
@@ -32,52 +23,70 @@ class CheckoutCartUpdateItemsAfterObserver implements ObserverInterface
* @var Cart
*/
protected $cart;
+ /**
+ * @var string
+ */
+ protected $endpoint;
+ /**
+ * @var Api
+ */
+ protected $api;
+ /**
+ * @var ConfigHelper
+ */
+ protected $configHelper;
+ /**
+ * @var ContextHelper
+ */
+ protected $contextHelper;
/**
* CheckoutCartUpdateItemsAfterObserver constructor.
*
- * @param ScopeConfigInterface $scopeConfig
- * @param Session $checkoutSession
+ * @param Cart $cart
+ * @param CustomerSession $customerSession
+ * @param Api $api
+ * @param ConfigHelper $configHelper
+ * @param ContextHelper $contextHelper
*/
- public function __construct(ScopeConfigInterface $scopeConfig, Session $checkoutSession, Cart $cart, CustomerSession $customerSession)
- {
- $this->scopeConfig = $scopeConfig;
- $this->checkoutSession = $checkoutSession;
+ public function __construct(
+ Cart $cart,
+ CustomerSession $customerSession,
+ Api $api,
+ ConfigHelper $configHelper,
+ ContextHelper $contextHelper
+ ) {
$this->customerSession = $customerSession;
- $this->cart = $cart;
+ $this->cart = $cart;
+ $this->api = $api;
+ $this->configHelper = $configHelper;
+ $this->contextHelper = $contextHelper;
}
/**
- * @param Observer $observer
+ * Event observer
+ *
+ * @param Observer $observer
* @return void
*/
- public function execute(\Magento\Framework\Event\Observer $observer)
+ public function execute(Observer $observer)
{
- if ($this->scopeConfig->getValue('clerk/product_synchronization/collect_baskets', ScopeInterface::SCOPE_STORE) == '1') {
- $cart_productIds = [];
- foreach ($this->cart->getQuote()->getAllVisibleItems() as $item) {
- if (!in_array($item->getProductId(), $cart_productIds)) {
- array_push($cart_productIds, $item->getProductId());
- }
- }
-
- if ($this->customerSession->isLoggedIn()) {
- $Endpoint = 'https://api.clerk.io/v2/log/basket/set';
-
- $data_string = json_encode([
- 'key' => $this->scopeConfig->getValue(Config::XML_PATH_PUBLIC_KEY, ScopeInterface::SCOPE_STORE),
- 'products' => $cart_productIds,
- 'email' => $this->customerSession->getCustomer()->getEmail()]);
-
- $curl = curl_init();
-
- curl_setopt($curl, CURLOPT_URL, $Endpoint);
- curl_setopt($curl, CURLOPT_POST, true);
- curl_setopt($curl, CURLOPT_RETURNTRANSFER, true);
- curl_setopt($curl, CURLOPT_POSTFIELDS, $data_string);
- curl_exec($curl);
-
+ if (!$this->configHelper->getValue(Config::XML_PATH_PRODUCT_SYNCHRONIZATION_COLLECT_EMAILS)
+ || !$this->configHelper->getValue(Config::XML_PATH_PRODUCT_SYNCHRONIZATION_COLLECT_BASKETS)
+ || !$this->customerSession->isLoggedIn()) {
+ return;
+ }
+ $cart_product_ids = [];
+ foreach ($this->cart->getQuote()->getAllVisibleItems() as $item) {
+ if (!in_array($item->getProductId(), $cart_product_ids)) {
+ $cart_product_ids[] = $item->getProductId();
}
}
+ $email = $this->customerSession->getCustomer()->getEmail();
+ try {
+ $this->api->logBasket($cart_product_ids, $email, $this->contextHelper->getStoreId());
+ } catch (Exception $e) {
+ return;
+ }
}
}
diff --git a/Observer/ControllerActionLayoutRenderBeforeObserver.php b/Observer/ControllerActionLayoutRenderBeforeObserver.php
index 37e323c..a6737f7 100644
--- a/Observer/ControllerActionLayoutRenderBeforeObserver.php
+++ b/Observer/ControllerActionLayoutRenderBeforeObserver.php
@@ -2,44 +2,44 @@
namespace Clerk\Clerk\Observer;
+use Clerk\Clerk\Helper\Config as ConfigHelper;
use Clerk\Clerk\Model\Config;
-use Magento\Framework\App\Config\ScopeConfigInterface;
use Magento\Framework\Event\Observer;
use Magento\Framework\Event\ObserverInterface;
-use Magento\Framework\View\Layout;
use Magento\Framework\View\Result\PageFactory;
-use Magento\Store\Model\ScopeInterface;
class ControllerActionLayoutRenderBeforeObserver implements ObserverInterface
{
- /**
- * @var ScopeConfigInterface
- */
- protected $scopeConfig;
-
/**
* @var PageFactory
*/
protected $resultPageFactory;
+ /**
+ * @var ConfigHelper
+ */
+ protected $configHelper;
/**
* LayoutGenerateBlocksAfterObserver constructor.
*
- * @param ScopeConfigInterface $scopeConfig
+ * @param ConfigHelper $configHelper
+ * @param PageFactory $resultPageFactory
*/
public function __construct(
- ScopeConfigInterface $scopeConfig,
+ ConfigHelper $configHelper,
PageFactory $resultPageFactory
) {
- $this->scopeConfig = $scopeConfig;
+ $this->configHelper = $configHelper;
$this->resultPageFactory = $resultPageFactory;
}
/**
+ * Event observer
+ *
* @param Observer $observer
* @return void
*/
- public function execute(\Magento\Framework\Event\Observer $observer)
+ public function execute(Observer $observer)
{
//Change page layout if faceted search is enabled
if (!$this->isFacetedSearchEnabled() && $this->isClerkSearchEnabled()) {
@@ -54,9 +54,9 @@ public function execute(\Magento\Framework\Event\Observer $observer)
*
* @return bool
*/
- private function isClerkSearchEnabled()
+ private function isFacetedSearchEnabled()
{
- return $this->scopeConfig->isSetFlag(Config::XML_PATH_SEARCH_ENABLED, ScopeInterface::SCOPE_STORE);
+ return $this->configHelper->getFlag(Config::XML_PATH_FACETED_SEARCH_ENABLED);
}
/**
@@ -64,8 +64,8 @@ private function isClerkSearchEnabled()
*
* @return bool
*/
- private function isFacetedSearchEnabled()
+ private function isClerkSearchEnabled()
{
- return $this->scopeConfig->isSetFlag(Config::XML_PATH_FACETED_SEARCH_ENABLED);
+ return $this->configHelper->getFlag(Config::XML_PATH_SEARCH_ENABLED);
}
}
diff --git a/Observer/LayoutLoadBeforeObserver.php b/Observer/LayoutLoadBeforeObserver.php
index 4c71ed7..9c8edb0 100644
--- a/Observer/LayoutLoadBeforeObserver.php
+++ b/Observer/LayoutLoadBeforeObserver.php
@@ -2,35 +2,37 @@
namespace Clerk\Clerk\Observer;
+use Clerk\Clerk\Helper\Config as ConfigHelper;
use Clerk\Clerk\Model\Config;
-use Magento\Framework\App\Config\ScopeConfigInterface;
use Magento\Framework\Event\Observer;
use Magento\Framework\Event\ObserverInterface;
use Magento\Framework\View\Layout;
-use Magento\Store\Model\ScopeInterface;
class LayoutLoadBeforeObserver implements ObserverInterface
{
/**
- * @var ScopeConfigInterface
+ * @var ConfigHelper
*/
- protected $scopeConfig;
+ protected $configHelper;
/**
* LayoutGenerateBlocksAfterObserver constructor.
*
- * @param ScopeConfigInterface $scopeConfig
+ * @param ConfigHelper $configHelper
*/
- public function __construct(ScopeConfigInterface $scopeConfig)
- {
- $this->scopeConfig = $scopeConfig;
+ public function __construct(
+ ConfigHelper $configHelper
+ ) {
+ $this->configHelper = $configHelper;
}
/**
+ * Event observer
+ *
* @param Observer $observer
* @return void
*/
- public function execute(\Magento\Framework\Event\Observer $observer)
+ public function execute(Observer $observer)
{
/** @var Layout $layout */
$layout = $observer->getLayout();
@@ -49,6 +51,6 @@ public function execute(\Magento\Framework\Event\Observer $observer)
*/
private function isClerkSearchEnabled()
{
- return $this->scopeConfig->isSetFlag(Config::XML_PATH_SEARCH_ENABLED, ScopeInterface::SCOPE_STORE);
+ return $this->configHelper->getFlag(Config::XML_PATH_SEARCH_ENABLED);
}
}
diff --git a/Observer/ProductDeleteAfterDoneObserver.php b/Observer/ProductDeleteAfterDoneObserver.php
index a30f644..363e665 100644
--- a/Observer/ProductDeleteAfterDoneObserver.php
+++ b/Observer/ProductDeleteAfterDoneObserver.php
@@ -4,18 +4,19 @@
use Clerk\Clerk\Model\Api;
use Clerk\Clerk\Model\Config;
+use Exception;
use Magento\Framework\App\Config\ScopeConfigInterface;
+use Magento\Framework\App\RequestInterface;
use Magento\Framework\Event\Observer;
use Magento\Framework\Event\ObserverInterface;
use Magento\Store\Model\ScopeInterface;
-use Magento\Framework\App\RequestInterface;
class ProductDeleteAfterDoneObserver implements ObserverInterface
{
/**
- * @var RequestInterface
- */
- protected $request;
+ * @var RequestInterface
+ */
+ protected $request;
/**
* @var ScopeConfigInterface
*/
@@ -26,12 +27,16 @@ class ProductDeleteAfterDoneObserver implements ObserverInterface
*/
protected $api;
+ /**
+ * @param ScopeConfigInterface $scopeConfig
+ * @param Api $api
+ * @param RequestInterface $request
+ */
public function __construct(
ScopeConfigInterface $scopeConfig,
- Api $api,
- RequestInterface $request
- )
- {
+ Api $api,
+ RequestInterface $request
+ ) {
$this->scopeConfig = $scopeConfig;
$this->api = $api;
$this->request = $request;
@@ -42,30 +47,17 @@ public function __construct(
*
* @param Observer $observer
* @return void
+ * @throws Exception
*/
- public function execute(\Magento\Framework\Event\Observer $observer)
+ public function execute(Observer $observer)
{
- $_params = $this->request->getParams();
- $scope_id = 0;
- $scope = 'default';
- if (array_key_exists('store', $_params)){
- $scope = 'store';
- $scope_id = $_params[$scope];
- }
$product = $observer->getEvent()->getProduct();
- if($product && $product->getId()){
- if($scope_id == 0){
- $store_ids_prod = $product->getStoreIds();
- foreach ($store_ids_prod as $store_id) {
- if ($this->scopeConfig->getValue(Config::XML_PATH_PRODUCT_SYNCHRONIZATION_REAL_TIME_ENABLED, 'store', $store_id)) {
- $this->api->removeProduct($product->getId(), $scope_id);
- }
- }
- } else {
- if ($this->scopeConfig->getValue(Config::XML_PATH_PRODUCT_SYNCHRONIZATION_REAL_TIME_ENABLED, $scope, $scope_id)) {
- $this->api->removeProduct($product->getId(), $scope_id);
- }
+ $product_store_ids = $product->getStoreIds();
+ foreach ($product_store_ids as $store_id) {
+ if (!$this->scopeConfig->getValue(Config::XML_PATH_PRODUCT_SYNCHRONIZATION_REAL_TIME_ENABLED, ScopeInterface::SCOPE_STORE, $store_id)) {
+ continue;
}
+ $this->api->removeProduct($product->getId(), $store_id);
}
}
}
diff --git a/Observer/ProductSaveAfterObserver.php b/Observer/ProductSaveAfterObserver.php
index edeacf7..d3be8b5 100644
--- a/Observer/ProductSaveAfterObserver.php
+++ b/Observer/ProductSaveAfterObserver.php
@@ -2,33 +2,29 @@
namespace Clerk\Clerk\Observer;
+use Clerk\Clerk\Controller\Logger\ClerkLogger;
+use Clerk\Clerk\Model\Adapter\Product as ProductAdapter;
use Clerk\Clerk\Model\Api;
use Clerk\Clerk\Model\Config;
+use Exception;
+use Magento\Catalog\Api\Data\ProductInterface;
+use Magento\Catalog\Api\ProductRepositoryInterface;
use Magento\Catalog\Model\Product;
+use Magento\Catalog\Model\Product as ProductModel;
+use Magento\ConfigurableProduct\Model\ResourceModel\Product\Type\Configurable as ProductModelConfigurable;
use Magento\Framework\App\Config\ScopeConfigInterface;
use Magento\Framework\App\RequestInterface;
use Magento\Framework\Event\ManagerInterface;
use Magento\Framework\Event\Observer;
use Magento\Framework\Event\ObserverInterface;
use Magento\Framework\Exception\NoSuchEntityException;
+use Magento\GroupedProduct\Model\Product\Type\Grouped as ProductModelGrouped;
use Magento\Store\Model\App\Emulation;
-use Magento\Store\Model\StoreManagerInterface;
-use Clerk\Clerk\Model\Adapter\Product as ProductAdapter;
-use Psr\Log\LoggerInterface;
use Magento\Store\Model\ScopeInterface;
-use Magento\Catalog\Api\ProductRepositoryInterface;
-
-use Magento\ConfigurableProduct\Model\ResourceModel\Product\Type\Configurable as ProductModelConfigurable;
-use Magento\GroupedProduct\Model\Product\Type\Grouped as ProductModelGrouped;
-use Magento\Catalog\Model\Product as ProductModel;
+use Magento\Store\Model\StoreManagerInterface;
class ProductSaveAfterObserver implements ObserverInterface
{
- /**
- * @var ProductModel
- */
- protected $_productModel;
-
/**
* @var ProductModelGrouped
*/
@@ -78,14 +74,14 @@ class ProductSaveAfterObserver implements ObserverInterface
* @var ProductRepositoryInterface
*/
protected $productRepository;
-
/**
- * @var LoggerInterface
+ * @var ClerkLogger
*/
- protected $logger;
+ protected $clerkLogger;
/**
* ProductSaveAfterObserver constructor.
+ *
* @param ScopeConfigInterface $scopeConfig
* @param ManagerInterface $eventManager
* @param RequestInterface $request
@@ -95,7 +91,8 @@ class ProductSaveAfterObserver implements ObserverInterface
* @param ProductAdapter $productAdapter
* @param ProductModelConfigurable $productModelConfigurable
* @param ProductModelGrouped $productModelGrouped
- * @param ProductModel $productModel
+ * @param ProductRepositoryInterface $productRepository
+ * @param ClerkLogger $clerkLogger
*/
public function __construct(
ScopeConfigInterface $scopeConfig,
@@ -107,116 +104,109 @@ public function __construct(
ProductAdapter $productAdapter,
ProductModelConfigurable $productModelConfigurable,
ProductModelGrouped $productModelGrouped,
- ProductModel $productModel,
ProductRepositoryInterface $productRepository,
- LoggerInterface $logger
+ ClerkLogger $clerkLogger
) {
- $this->scopeConfig = $scopeConfig;
- $this->eventManager = $eventManager;
- $this->request = $request;
- $this->emulation = $emulation;
- $this->storeManager = $storeManager;
- $this->api = $api;
- $this->productAdapter = $productAdapter;
+ $this->scopeConfig = $scopeConfig;
+ $this->eventManager = $eventManager;
+ $this->request = $request;
+ $this->emulation = $emulation;
+ $this->storeManager = $storeManager;
+ $this->api = $api;
+ $this->productAdapter = $productAdapter;
$this->productRepository = $productRepository;
- $this->logger = $logger;
$this->_productModelConfigurable = $productModelConfigurable;
- $this->_productModelGrouped = $productModelGrouped;
- $this->_productModel = $productModel;
+ $this->_productModelGrouped = $productModelGrouped;
+ $this->clerkLogger = $clerkLogger;
}
/**
* Add product to Clerk
*
- * @param Observer $observer
+ * @param Observer $observer
* @return void
+ * @throws NoSuchEntityException
*/
- public function execute(\Magento\Framework\Event\Observer $observer)
+ public function execute(Observer $observer)
{
- $_params = $this->request->getParams();
- $storeId = 0;
- $scope = 'default';
- if (array_key_exists('store', $_params)){
- $scope = 'store';
- $storeId = $_params[$scope];
- }
$product = $observer->getEvent()->getProduct();
- if ($storeId == 0) {
- //Update all stores the product is connected to
- $productstoreIds = $product->getStoreIds();
- foreach ($productstoreIds as $productstoreId) {
- $product = $this->productRepository->getById($product->getId(), false, $productstoreId);
- if ($this->storeManager->getStore($productstoreId)->isActive() == true) {
- try {
- $this->updateStore($product, $productstoreId);
- } catch (NoSuchEntityException $e) {
- $this->logger->error('Updating Products Error', ['error' => $e->getMessage()]);
- } finally {
- $this->emulation->stopEnvironmentEmulation();
- }
+ $product_store_ids = $product->getStoreIds();
+ foreach ($product_store_ids as $store_id) {
+ $product = $this->productRepository->getById($product->getId(), false, $store_id);
+ if ($this->storeManager->getStore($store_id)->isActive()) {
+ try {
+ $this->updateStore($product, $store_id);
+ } finally {
+ $this->emulation->stopEnvironmentEmulation();
}
}
- } else {
- //Update single store
- try {
- $this->updateStore($product, $storeId);
- } finally {
- $this->emulation->stopEnvironmentEmulation();
- }
}
}
/**
- * @param $storeId
+ * Update store with product data
+ *
+ * @param ProductModel|ProductInterface $product
+ * @param int|string $store_id
*/
- protected function updateStore(Product $product, $storeId)
+ protected function updateStore(Product $product, $store_id)
{
- $this->emulation->startEnvironmentEmulation($storeId);
- if ($this->scopeConfig->getValue(Config::XML_PATH_PRODUCT_SYNCHRONIZATION_REAL_TIME_ENABLED, ScopeInterface::SCOPE_STORE, $storeId)) {
- if ($product->getId()) {
-
- //Cancel if product visibility is not as defined
- if( 'any' != $this->scopeConfig->getValue(Config::XML_PATH_PRODUCT_SYNCHRONIZATION_VISIBILITY, ScopeInterface::SCOPE_STORE, $storeId) ) {
- if ($product->getVisibility() != $this->scopeConfig->getValue(Config::XML_PATH_PRODUCT_SYNCHRONIZATION_VISIBILITY, ScopeInterface::SCOPE_STORE, $storeId)) {
- return;
- }
- }
+ $this->emulation->startEnvironmentEmulation($store_id);
- //Cancel if product is not saleable
- if ($this->scopeConfig->getValue(Config::XML_PATH_PRODUCT_SYNCHRONIZATION_SALABLE_ONLY, ScopeInterface::SCOPE_STORE, $storeId)) {
- if (!$product->isSalable()) {
- return;
- }
+ if (!$this->scopeConfig->getValue(Config::XML_PATH_PRODUCT_SYNCHRONIZATION_REAL_TIME_ENABLED, ScopeInterface::SCOPE_STORE, $store_id)) {
+ return;
+ }
+ if (!$product->getId()) {
+ return;
+ }
+ // Cancel if product visibility is not as defined
+ if ('any' != $this->scopeConfig->getValue(Config::XML_PATH_PRODUCT_SYNCHRONIZATION_VISIBILITY, ScopeInterface::SCOPE_STORE, $store_id)) {
+ if ($product->getVisibility() != $this->scopeConfig->getValue(Config::XML_PATH_PRODUCT_SYNCHRONIZATION_VISIBILITY, ScopeInterface::SCOPE_STORE, $store_id)) {
+ try {
+ $this->api->removeProduct($product->getId());
+ } catch (Exception $e) {
+ return;
}
-
- // 21-10-2021 KKY update parent products if in Grouped or child to Configurable before we check visibility and saleable - start
-
- $confParentProductIds = $this->_productModelConfigurable->getParentIdsByChild($product->getId());
- if (isset($confParentProductIds[0])) {
- $confparentproduct = $this->_productModel->load($confParentProductIds[0]);
-
- $productInfo = $this->productAdapter->getInfoForItem($confparentproduct, 'store', $storeId);
- $this->api->addProduct($productInfo, $storeId);
-
+ }
+ }
+ // Cancel if product is not saleable
+ if ($this->scopeConfig->getValue(Config::XML_PATH_PRODUCT_SYNCHRONIZATION_SALABLE_ONLY, ScopeInterface::SCOPE_STORE, $store_id)) {
+ if (!$product->isSalable()) {
+ try {
+ $this->api->removeProduct($product->getId());
+ } catch (Exception $e) {
+ return;
}
- $groupParentProductIds = $this->_productModelGrouped->getParentIdsByChild($product->getId());
- if (isset($groupParentProductIds[0])) {
- foreach ($groupParentProductIds as $groupParentProductId) {
- $groupparentproduct = $this->_productModel->load($groupParentProductId);
+ }
+ }
- $productInfo = $this->productAdapter->getInfoForItem($groupparentproduct, 'store', $storeId);
- $this->api->addProduct($productInfo, $storeId);
+ $parent_product_ids = $this->_productModelConfigurable->getParentIdsByChild($product->getId());
+ if (!empty($parent_product_ids)) {
+ try {
+ $parent_product = $this->productRepository->getById((int)$parent_product_ids[0], false, $store_id);
+ $parent_product_data =
+ $this->productAdapter->getInfoForItem($parent_product, ScopeInterface::SCOPE_STORE, $store_id);
+ $this->api->addProduct($parent_product_data, $store_id);
+ } catch (NoSuchEntityException $e) {
+ $this->clerkLogger->error('No parent products', ['warning' => $e->getMessage()]);
+ }
+ }
- }
+ $group_parent_product_ids = $this->_productModelGrouped->getParentIdsByChild($product->getId());
+ if (!empty($group_parent_product_ids)) {
+ foreach ($group_parent_product_ids as $group_parent_product_id) {
+ try {
+ $group_parent_product =
+ $this->productRepository->getById((int)$group_parent_product_id, false, $store_id);
+ $group_parent_product_data =
+ $this->productAdapter->getInfoForItem($group_parent_product, ScopeInterface::SCOPE_STORE, $store_id);
+ $this->api->addProduct($group_parent_product_data, $store_id);
+ } catch (NoSuchEntityException $e) {
+ $this->clerkLogger->error('No parent products', ['warning' => $e->getMessage()]);
}
-
- // 21-10-2021 KKY update parent products if in Grouped or child to Configurable - end
-
- $productInfo = $this->productAdapter->getInfoForItem($product, 'store', $storeId);
-
- $this->api->addProduct($productInfo, $storeId);
-
}
}
+ $product_data = $this->productAdapter->getInfoForItem($product, 'store', $store_id);
+ $this->api->addProduct($product_data, $store_id);
}
}
diff --git a/Observer/SalesOrderCreditmemoSaveAfterObserver.php b/Observer/SalesOrderCreditmemoSaveAfterObserver.php
index 495e0fc..447ad6f 100644
--- a/Observer/SalesOrderCreditmemoSaveAfterObserver.php
+++ b/Observer/SalesOrderCreditmemoSaveAfterObserver.php
@@ -7,8 +7,8 @@
use Magento\Framework\App\Config\ScopeConfigInterface;
use Magento\Framework\Event\Observer;
use Magento\Framework\Event\ObserverInterface;
-use Magento\Store\Model\ScopeInterface;
use Magento\Sales\Api\OrderRepositoryInterface;
+use Magento\Store\Model\ScopeInterface;
class SalesOrderCreditmemoSaveAfterObserver implements ObserverInterface
{
@@ -27,8 +27,16 @@ class SalesOrderCreditmemoSaveAfterObserver implements ObserverInterface
*/
protected $orderRepository;
- public function __construct(ScopeConfigInterface $scopeConfig, Api $api, OrderRepositoryInterface $orderRepository)
- {
+ /**
+ * @param ScopeConfigInterface $scopeConfig
+ * @param Api $api
+ * @param OrderRepositoryInterface $orderRepository
+ */
+ public function __construct(
+ ScopeConfigInterface $scopeConfig,
+ Api $api,
+ OrderRepositoryInterface $orderRepository
+ ) {
$this->orderRepository = $orderRepository;
$this->scopeConfig = $scopeConfig;
$this->api = $api;
@@ -40,25 +48,22 @@ public function __construct(ScopeConfigInterface $scopeConfig, Api $api, OrderRe
* @param Observer $observer
* @return void
*/
- public function execute(\Magento\Framework\Event\Observer $observer)
+ public function execute(Observer $observer)
{
- if ($this->scopeConfig->getValue(Config::XML_PATH_PRODUCT_SYNCHRONIZATION_ENABLE_ORDER_RETURN_SYNCHRONIZATION, ScopeInterface::SCOPE_STORE)) {
-
- $creditmemo = $observer->getEvent()->getCreditmemo();
- $order_id = $creditmemo->getOrderId();
- $order = $this->orderRepository->get($order_id);
- $orderIncrementId = $order->getIncrementId();
- $store_id = $order->getStore()->getId();
-
- foreach ($creditmemo->getAllItems() as $item) {
-
- $product_id = $item->getProductId();
- $quantity = $item->getQty();
-
- if ($product_id && $orderIncrementId && $quantity !=0) {
- $this->api->returnProduct($orderIncrementId, $product_id, $quantity, $store_id);
- }
+ $creditmemo = $observer->getEvent()->getCreditmemo();
+ $order_id = $creditmemo->getOrderId();
+ $order = $this->orderRepository->get($order_id);
+ $order_increment_id = $order->getIncrementId();
+ $store_id = $order->getStore()->getId();
+ if (!$this->scopeConfig->getValue(Config::XML_PATH_PRODUCT_SYNCHRONIZATION_ENABLE_ORDER_RETURN_SYNCHRONIZATION, ScopeInterface::SCOPE_STORE, $store_id)) {
+ return;
+ }
+ foreach ($creditmemo->getAllItems() as $item) {
+ $product_id = $item->getProductId();
+ $quantity = $item->getQty();
+ if ($product_id && $order_increment_id && $quantity !=0) {
+ $this->api->returnProduct($order_increment_id, $product_id, $quantity, $store_id);
}
}
}
diff --git a/composer.json b/composer.json
index 7ad4433..5b7edb9 100644
--- a/composer.json
+++ b/composer.json
@@ -28,5 +28,16 @@
"psr-4": {
"Clerk\\Clerk\\": ""
}
+ },
+ "require-dev": {
+ "magento/magento-coding-standard": "^33.0",
+ "composer": "*",
+ "psr/log": "^3.0",
+ "friendsofphp/php-cs-fixer": "^3.62"
+ },
+ "config": {
+ "allow-plugins": {
+ "dealerdirect/phpcodesniffer-composer-installer": true
+ }
}
}
diff --git a/composer.lock b/composer.lock
index 8313927..1df4613 100644
--- a/composer.lock
+++ b/composer.lock
@@ -4,328 +4,3062 @@
"Read more about it at https://getcomposer.org/doc/01-basic-usage.md#installing-dependencies",
"This file is @generated automatically"
],
- "content-hash": "6a1fcfe4abb5d90b192a42d0686ea1ae",
- "packages": [
+ "content-hash": "50fa91725e0a10864191f06808b83a0d",
+ "packages": [],
+ "packages-dev": [
+ {
+ "name": "clue/ndjson-react",
+ "version": "v1.3.0",
+ "source": {
+ "type": "git",
+ "url": "https://github.com/clue/reactphp-ndjson.git",
+ "reference": "392dc165fce93b5bb5c637b67e59619223c931b0"
+ },
+ "dist": {
+ "type": "zip",
+ "url": "https://api.github.com/repos/clue/reactphp-ndjson/zipball/392dc165fce93b5bb5c637b67e59619223c931b0",
+ "reference": "392dc165fce93b5bb5c637b67e59619223c931b0",
+ "shasum": ""
+ },
+ "require": {
+ "php": ">=5.3",
+ "react/stream": "^1.2"
+ },
+ "require-dev": {
+ "phpunit/phpunit": "^9.5 || ^5.7 || ^4.8.35",
+ "react/event-loop": "^1.2"
+ },
+ "type": "library",
+ "autoload": {
+ "psr-4": {
+ "Clue\\React\\NDJson\\": "src/"
+ }
+ },
+ "notification-url": "https://packagist.org/downloads/",
+ "license": [
+ "MIT"
+ ],
+ "authors": [
+ {
+ "name": "Christian Lück",
+ "email": "christian@clue.engineering"
+ }
+ ],
+ "description": "Streaming newline-delimited JSON (NDJSON) parser and encoder for ReactPHP.",
+ "homepage": "https://github.com/clue/reactphp-ndjson",
+ "keywords": [
+ "NDJSON",
+ "json",
+ "jsonlines",
+ "newline",
+ "reactphp",
+ "streaming"
+ ],
+ "support": {
+ "issues": "https://github.com/clue/reactphp-ndjson/issues",
+ "source": "https://github.com/clue/reactphp-ndjson/tree/v1.3.0"
+ },
+ "funding": [
+ {
+ "url": "https://clue.engineering/support",
+ "type": "custom"
+ },
+ {
+ "url": "https://github.com/clue",
+ "type": "github"
+ }
+ ],
+ "time": "2022-12-23T10:58:28+00:00"
+ },
+ {
+ "name": "composer/pcre",
+ "version": "3.3.0",
+ "source": {
+ "type": "git",
+ "url": "https://github.com/composer/pcre.git",
+ "reference": "1637e067347a0c40bbb1e3cd786b20dcab556a81"
+ },
+ "dist": {
+ "type": "zip",
+ "url": "https://api.github.com/repos/composer/pcre/zipball/1637e067347a0c40bbb1e3cd786b20dcab556a81",
+ "reference": "1637e067347a0c40bbb1e3cd786b20dcab556a81",
+ "shasum": ""
+ },
+ "require": {
+ "php": "^7.4 || ^8.0"
+ },
+ "conflict": {
+ "phpstan/phpstan": "<1.11.10"
+ },
+ "require-dev": {
+ "phpstan/phpstan": "^1.11.10",
+ "phpstan/phpstan-strict-rules": "^1.1",
+ "phpunit/phpunit": "^8 || ^9"
+ },
+ "type": "library",
+ "extra": {
+ "branch-alias": {
+ "dev-main": "3.x-dev"
+ },
+ "phpstan": {
+ "includes": [
+ "extension.neon"
+ ]
+ }
+ },
+ "autoload": {
+ "psr-4": {
+ "Composer\\Pcre\\": "src"
+ }
+ },
+ "notification-url": "https://packagist.org/downloads/",
+ "license": [
+ "MIT"
+ ],
+ "authors": [
+ {
+ "name": "Jordi Boggiano",
+ "email": "j.boggiano@seld.be",
+ "homepage": "http://seld.be"
+ }
+ ],
+ "description": "PCRE wrapping library that offers type-safe preg_* replacements.",
+ "keywords": [
+ "PCRE",
+ "preg",
+ "regex",
+ "regular expression"
+ ],
+ "support": {
+ "issues": "https://github.com/composer/pcre/issues",
+ "source": "https://github.com/composer/pcre/tree/3.3.0"
+ },
+ "funding": [
+ {
+ "url": "https://packagist.com",
+ "type": "custom"
+ },
+ {
+ "url": "https://github.com/composer",
+ "type": "github"
+ },
+ {
+ "url": "https://tidelift.com/funding/github/packagist/composer/composer",
+ "type": "tidelift"
+ }
+ ],
+ "time": "2024-08-19T19:43:53+00:00"
+ },
+ {
+ "name": "composer/semver",
+ "version": "3.4.2",
+ "source": {
+ "type": "git",
+ "url": "https://github.com/composer/semver.git",
+ "reference": "c51258e759afdb17f1fd1fe83bc12baaef6309d6"
+ },
+ "dist": {
+ "type": "zip",
+ "url": "https://api.github.com/repos/composer/semver/zipball/c51258e759afdb17f1fd1fe83bc12baaef6309d6",
+ "reference": "c51258e759afdb17f1fd1fe83bc12baaef6309d6",
+ "shasum": ""
+ },
+ "require": {
+ "php": "^5.3.2 || ^7.0 || ^8.0"
+ },
+ "require-dev": {
+ "phpstan/phpstan": "^1.4",
+ "symfony/phpunit-bridge": "^4.2 || ^5"
+ },
+ "type": "library",
+ "extra": {
+ "branch-alias": {
+ "dev-main": "3.x-dev"
+ }
+ },
+ "autoload": {
+ "psr-4": {
+ "Composer\\Semver\\": "src"
+ }
+ },
+ "notification-url": "https://packagist.org/downloads/",
+ "license": [
+ "MIT"
+ ],
+ "authors": [
+ {
+ "name": "Nils Adermann",
+ "email": "naderman@naderman.de",
+ "homepage": "http://www.naderman.de"
+ },
+ {
+ "name": "Jordi Boggiano",
+ "email": "j.boggiano@seld.be",
+ "homepage": "http://seld.be"
+ },
+ {
+ "name": "Rob Bast",
+ "email": "rob.bast@gmail.com",
+ "homepage": "http://robbast.nl"
+ }
+ ],
+ "description": "Semver library that offers utilities, version constraint parsing and validation.",
+ "keywords": [
+ "semantic",
+ "semver",
+ "validation",
+ "versioning"
+ ],
+ "support": {
+ "irc": "ircs://irc.libera.chat:6697/composer",
+ "issues": "https://github.com/composer/semver/issues",
+ "source": "https://github.com/composer/semver/tree/3.4.2"
+ },
+ "funding": [
+ {
+ "url": "https://packagist.com",
+ "type": "custom"
+ },
+ {
+ "url": "https://github.com/composer",
+ "type": "github"
+ },
+ {
+ "url": "https://tidelift.com/funding/github/packagist/composer/composer",
+ "type": "tidelift"
+ }
+ ],
+ "time": "2024-07-12T11:35:52+00:00"
+ },
+ {
+ "name": "composer/xdebug-handler",
+ "version": "3.0.5",
+ "source": {
+ "type": "git",
+ "url": "https://github.com/composer/xdebug-handler.git",
+ "reference": "6c1925561632e83d60a44492e0b344cf48ab85ef"
+ },
+ "dist": {
+ "type": "zip",
+ "url": "https://api.github.com/repos/composer/xdebug-handler/zipball/6c1925561632e83d60a44492e0b344cf48ab85ef",
+ "reference": "6c1925561632e83d60a44492e0b344cf48ab85ef",
+ "shasum": ""
+ },
+ "require": {
+ "composer/pcre": "^1 || ^2 || ^3",
+ "php": "^7.2.5 || ^8.0",
+ "psr/log": "^1 || ^2 || ^3"
+ },
+ "require-dev": {
+ "phpstan/phpstan": "^1.0",
+ "phpstan/phpstan-strict-rules": "^1.1",
+ "phpunit/phpunit": "^8.5 || ^9.6 || ^10.5"
+ },
+ "type": "library",
+ "autoload": {
+ "psr-4": {
+ "Composer\\XdebugHandler\\": "src"
+ }
+ },
+ "notification-url": "https://packagist.org/downloads/",
+ "license": [
+ "MIT"
+ ],
+ "authors": [
+ {
+ "name": "John Stevenson",
+ "email": "john-stevenson@blueyonder.co.uk"
+ }
+ ],
+ "description": "Restarts a process without Xdebug.",
+ "keywords": [
+ "Xdebug",
+ "performance"
+ ],
+ "support": {
+ "irc": "ircs://irc.libera.chat:6697/composer",
+ "issues": "https://github.com/composer/xdebug-handler/issues",
+ "source": "https://github.com/composer/xdebug-handler/tree/3.0.5"
+ },
+ "funding": [
+ {
+ "url": "https://packagist.com",
+ "type": "custom"
+ },
+ {
+ "url": "https://github.com/composer",
+ "type": "github"
+ },
+ {
+ "url": "https://tidelift.com/funding/github/packagist/composer/composer",
+ "type": "tidelift"
+ }
+ ],
+ "time": "2024-05-06T16:37:16+00:00"
+ },
+ {
+ "name": "dealerdirect/phpcodesniffer-composer-installer",
+ "version": "v1.0.0",
+ "source": {
+ "type": "git",
+ "url": "https://github.com/PHPCSStandards/composer-installer.git",
+ "reference": "4be43904336affa5c2f70744a348312336afd0da"
+ },
+ "dist": {
+ "type": "zip",
+ "url": "https://api.github.com/repos/PHPCSStandards/composer-installer/zipball/4be43904336affa5c2f70744a348312336afd0da",
+ "reference": "4be43904336affa5c2f70744a348312336afd0da",
+ "shasum": ""
+ },
+ "require": {
+ "composer-plugin-api": "^1.0 || ^2.0",
+ "php": ">=5.4",
+ "squizlabs/php_codesniffer": "^2.0 || ^3.1.0 || ^4.0"
+ },
+ "require-dev": {
+ "composer/composer": "*",
+ "ext-json": "*",
+ "ext-zip": "*",
+ "php-parallel-lint/php-parallel-lint": "^1.3.1",
+ "phpcompatibility/php-compatibility": "^9.0",
+ "yoast/phpunit-polyfills": "^1.0"
+ },
+ "type": "composer-plugin",
+ "extra": {
+ "class": "PHPCSStandards\\Composer\\Plugin\\Installers\\PHPCodeSniffer\\Plugin"
+ },
+ "autoload": {
+ "psr-4": {
+ "PHPCSStandards\\Composer\\Plugin\\Installers\\PHPCodeSniffer\\": "src/"
+ }
+ },
+ "notification-url": "https://packagist.org/downloads/",
+ "license": [
+ "MIT"
+ ],
+ "authors": [
+ {
+ "name": "Franck Nijhof",
+ "email": "franck.nijhof@dealerdirect.com",
+ "homepage": "http://www.frenck.nl",
+ "role": "Developer / IT Manager"
+ },
+ {
+ "name": "Contributors",
+ "homepage": "https://github.com/PHPCSStandards/composer-installer/graphs/contributors"
+ }
+ ],
+ "description": "PHP_CodeSniffer Standards Composer Installer Plugin",
+ "homepage": "http://www.dealerdirect.com",
+ "keywords": [
+ "PHPCodeSniffer",
+ "PHP_CodeSniffer",
+ "code quality",
+ "codesniffer",
+ "composer",
+ "installer",
+ "phpcbf",
+ "phpcs",
+ "plugin",
+ "qa",
+ "quality",
+ "standard",
+ "standards",
+ "style guide",
+ "stylecheck",
+ "tests"
+ ],
+ "support": {
+ "issues": "https://github.com/PHPCSStandards/composer-installer/issues",
+ "source": "https://github.com/PHPCSStandards/composer-installer"
+ },
+ "time": "2023-01-05T11:28:13+00:00"
+ },
+ {
+ "name": "evenement/evenement",
+ "version": "v3.0.2",
+ "source": {
+ "type": "git",
+ "url": "https://github.com/igorw/evenement.git",
+ "reference": "0a16b0d71ab13284339abb99d9d2bd813640efbc"
+ },
+ "dist": {
+ "type": "zip",
+ "url": "https://api.github.com/repos/igorw/evenement/zipball/0a16b0d71ab13284339abb99d9d2bd813640efbc",
+ "reference": "0a16b0d71ab13284339abb99d9d2bd813640efbc",
+ "shasum": ""
+ },
+ "require": {
+ "php": ">=7.0"
+ },
+ "require-dev": {
+ "phpunit/phpunit": "^9 || ^6"
+ },
+ "type": "library",
+ "autoload": {
+ "psr-4": {
+ "Evenement\\": "src/"
+ }
+ },
+ "notification-url": "https://packagist.org/downloads/",
+ "license": [
+ "MIT"
+ ],
+ "authors": [
+ {
+ "name": "Igor Wiedler",
+ "email": "igor@wiedler.ch"
+ }
+ ],
+ "description": "Événement is a very simple event dispatching library for PHP",
+ "keywords": [
+ "event-dispatcher",
+ "event-emitter"
+ ],
+ "support": {
+ "issues": "https://github.com/igorw/evenement/issues",
+ "source": "https://github.com/igorw/evenement/tree/v3.0.2"
+ },
+ "time": "2023-08-08T05:53:35+00:00"
+ },
+ {
+ "name": "fidry/cpu-core-counter",
+ "version": "1.1.0",
+ "source": {
+ "type": "git",
+ "url": "https://github.com/theofidry/cpu-core-counter.git",
+ "reference": "f92996c4d5c1a696a6a970e20f7c4216200fcc42"
+ },
+ "dist": {
+ "type": "zip",
+ "url": "https://api.github.com/repos/theofidry/cpu-core-counter/zipball/f92996c4d5c1a696a6a970e20f7c4216200fcc42",
+ "reference": "f92996c4d5c1a696a6a970e20f7c4216200fcc42",
+ "shasum": ""
+ },
+ "require": {
+ "php": "^7.2 || ^8.0"
+ },
+ "require-dev": {
+ "fidry/makefile": "^0.2.0",
+ "fidry/php-cs-fixer-config": "^1.1.2",
+ "phpstan/extension-installer": "^1.2.0",
+ "phpstan/phpstan": "^1.9.2",
+ "phpstan/phpstan-deprecation-rules": "^1.0.0",
+ "phpstan/phpstan-phpunit": "^1.2.2",
+ "phpstan/phpstan-strict-rules": "^1.4.4",
+ "phpunit/phpunit": "^8.5.31 || ^9.5.26",
+ "webmozarts/strict-phpunit": "^7.5"
+ },
+ "type": "library",
+ "autoload": {
+ "psr-4": {
+ "Fidry\\CpuCoreCounter\\": "src/"
+ }
+ },
+ "notification-url": "https://packagist.org/downloads/",
+ "license": [
+ "MIT"
+ ],
+ "authors": [
+ {
+ "name": "Théo FIDRY",
+ "email": "theo.fidry@gmail.com"
+ }
+ ],
+ "description": "Tiny utility to get the number of CPU cores.",
+ "keywords": [
+ "CPU",
+ "core"
+ ],
+ "support": {
+ "issues": "https://github.com/theofidry/cpu-core-counter/issues",
+ "source": "https://github.com/theofidry/cpu-core-counter/tree/1.1.0"
+ },
+ "funding": [
+ {
+ "url": "https://github.com/theofidry",
+ "type": "github"
+ }
+ ],
+ "time": "2024-02-07T09:43:46+00:00"
+ },
+ {
+ "name": "friendsofphp/php-cs-fixer",
+ "version": "v3.62.0",
+ "source": {
+ "type": "git",
+ "url": "https://github.com/PHP-CS-Fixer/PHP-CS-Fixer.git",
+ "reference": "627692f794d35c43483f34b01d94740df2a73507"
+ },
+ "dist": {
+ "type": "zip",
+ "url": "https://api.github.com/repos/PHP-CS-Fixer/PHP-CS-Fixer/zipball/627692f794d35c43483f34b01d94740df2a73507",
+ "reference": "627692f794d35c43483f34b01d94740df2a73507",
+ "shasum": ""
+ },
+ "require": {
+ "clue/ndjson-react": "^1.0",
+ "composer/semver": "^3.4",
+ "composer/xdebug-handler": "^3.0.3",
+ "ext-filter": "*",
+ "ext-json": "*",
+ "ext-tokenizer": "*",
+ "fidry/cpu-core-counter": "^1.0",
+ "php": "^7.4 || ^8.0",
+ "react/child-process": "^0.6.5",
+ "react/event-loop": "^1.0",
+ "react/promise": "^2.0 || ^3.0",
+ "react/socket": "^1.0",
+ "react/stream": "^1.0",
+ "sebastian/diff": "^4.0 || ^5.0 || ^6.0",
+ "symfony/console": "^5.4 || ^6.0 || ^7.0",
+ "symfony/event-dispatcher": "^5.4 || ^6.0 || ^7.0",
+ "symfony/filesystem": "^5.4 || ^6.0 || ^7.0",
+ "symfony/finder": "^5.4 || ^6.0 || ^7.0",
+ "symfony/options-resolver": "^5.4 || ^6.0 || ^7.0",
+ "symfony/polyfill-mbstring": "^1.28",
+ "symfony/polyfill-php80": "^1.28",
+ "symfony/polyfill-php81": "^1.28",
+ "symfony/process": "^5.4 || ^6.0 || ^7.0",
+ "symfony/stopwatch": "^5.4 || ^6.0 || ^7.0"
+ },
+ "require-dev": {
+ "facile-it/paraunit": "^1.3 || ^2.3",
+ "infection/infection": "^0.29.5",
+ "justinrainbow/json-schema": "^5.2",
+ "keradus/cli-executor": "^2.1",
+ "mikey179/vfsstream": "^1.6.11",
+ "php-coveralls/php-coveralls": "^2.7",
+ "php-cs-fixer/accessible-object": "^1.1",
+ "php-cs-fixer/phpunit-constraint-isidenticalstring": "^1.5",
+ "php-cs-fixer/phpunit-constraint-xmlmatchesxsd": "^1.5",
+ "phpunit/phpunit": "^9.6.19 || ^10.5.21 || ^11.2",
+ "symfony/var-dumper": "^5.4 || ^6.0 || ^7.0",
+ "symfony/yaml": "^5.4 || ^6.0 || ^7.0"
+ },
+ "suggest": {
+ "ext-dom": "For handling output formats in XML",
+ "ext-mbstring": "For handling non-UTF8 characters."
+ },
+ "bin": [
+ "php-cs-fixer"
+ ],
+ "type": "application",
+ "autoload": {
+ "psr-4": {
+ "PhpCsFixer\\": "src/"
+ },
+ "exclude-from-classmap": [
+ "src/Fixer/Internal/*"
+ ]
+ },
+ "notification-url": "https://packagist.org/downloads/",
+ "license": [
+ "MIT"
+ ],
+ "authors": [
+ {
+ "name": "Fabien Potencier",
+ "email": "fabien@symfony.com"
+ },
+ {
+ "name": "Dariusz Rumiński",
+ "email": "dariusz.ruminski@gmail.com"
+ }
+ ],
+ "description": "A tool to automatically fix PHP code style",
+ "keywords": [
+ "Static code analysis",
+ "fixer",
+ "standards",
+ "static analysis"
+ ],
+ "support": {
+ "issues": "https://github.com/PHP-CS-Fixer/PHP-CS-Fixer/issues",
+ "source": "https://github.com/PHP-CS-Fixer/PHP-CS-Fixer/tree/v3.62.0"
+ },
+ "funding": [
+ {
+ "url": "https://github.com/keradus",
+ "type": "github"
+ }
+ ],
+ "time": "2024-08-07T17:03:09+00:00"
+ },
{
"name": "magento/magento-coding-standard",
- "version": "27",
+ "version": "33",
+ "source": {
+ "type": "git",
+ "url": "https://github.com/magento/magento-coding-standard.git",
+ "reference": "75215870d446f955ea08acdad9badff647117cfa"
+ },
+ "dist": {
+ "type": "zip",
+ "url": "https://api.github.com/repos/magento/magento-coding-standard/zipball/75215870d446f955ea08acdad9badff647117cfa",
+ "reference": "75215870d446f955ea08acdad9badff647117cfa",
+ "shasum": ""
+ },
+ "require": {
+ "ext-dom": "*",
+ "ext-simplexml": "*",
+ "magento/php-compatibility-fork": "^0.1",
+ "php": "~8.1.0 || ~8.2.0 || ~8.3.0",
+ "phpcsstandards/phpcsutils": "^1.0.5",
+ "rector/rector": "^0.17.12",
+ "squizlabs/php_codesniffer": "^3.6.1",
+ "webonyx/graphql-php": "^15.0"
+ },
+ "require-dev": {
+ "phpunit/phpunit": "^9.5.10",
+ "yoast/phpunit-polyfills": "^1.0"
+ },
+ "type": "phpcodesniffer-standard",
+ "autoload": {
+ "psr-4": {
+ "Magento2\\": "Magento2/",
+ "Magento2Framework\\": "Magento2Framework/"
+ },
+ "classmap": [
+ "PHP_CodeSniffer/Tokenizers/"
+ ]
+ },
+ "notification-url": "https://packagist.org/downloads/",
+ "license": [
+ "OSL-3.0",
+ "AFL-3.0"
+ ],
+ "description": "A set of Magento specific PHP CodeSniffer rules.",
+ "support": {
+ "issues": "https://github.com/magento/magento-coding-standard/issues",
+ "source": "https://github.com/magento/magento-coding-standard/tree/v33"
+ },
+ "time": "2023-12-19T17:16:36+00:00"
+ },
+ {
+ "name": "magento/php-compatibility-fork",
+ "version": "v0.1.0",
+ "source": {
+ "type": "git",
+ "url": "https://github.com/magento/PHPCompatibilityFork.git",
+ "reference": "1cf031c2a68e3e52e460c5690ed8d1d6d45f4653"
+ },
+ "dist": {
+ "type": "zip",
+ "url": "https://api.github.com/repos/magento/PHPCompatibilityFork/zipball/1cf031c2a68e3e52e460c5690ed8d1d6d45f4653",
+ "reference": "1cf031c2a68e3e52e460c5690ed8d1d6d45f4653",
+ "shasum": ""
+ },
+ "require": {
+ "php": ">=5.4",
+ "phpcsstandards/phpcsutils": "^1.0.5",
+ "squizlabs/php_codesniffer": "^3.7.1"
+ },
+ "replace": {
+ "phpcompatibility/php-compatibility": "*",
+ "wimg/php-compatibility": "*"
+ },
+ "require-dev": {
+ "php-parallel-lint/php-console-highlighter": "^1.0.0",
+ "php-parallel-lint/php-parallel-lint": "^1.3.2",
+ "phpcsstandards/phpcsdevcs": "^1.1.3",
+ "phpcsstandards/phpcsdevtools": "^1.2.0",
+ "phpunit/phpunit": "^4.8.36 || ^5.7.21 || ^6.0 || ^7.0 || ^8.0 || ^9.3.4 || ^10.1.0",
+ "yoast/phpunit-polyfills": "^1.0.5 || ^2.0.0"
+ },
+ "suggest": {
+ "roave/security-advisories": "dev-master || Helps prevent installing dependencies with known security issues."
+ },
+ "type": "phpcodesniffer-standard",
+ "notification-url": "https://packagist.org/downloads/",
+ "license": [
+ "LGPL-3.0-or-later"
+ ],
+ "authors": [
+ {
+ "name": "Wim Godden",
+ "homepage": "https://github.com/wimg",
+ "role": "lead"
+ },
+ {
+ "name": "Juliette Reinders Folmer",
+ "homepage": "https://github.com/jrfnl",
+ "role": "lead"
+ },
+ {
+ "name": "Contributors",
+ "homepage": "https://github.com/PHPCompatibility/PHPCompatibility/graphs/contributors"
+ }
+ ],
+ "description": "A set of sniffs for PHP_CodeSniffer that checks for PHP cross-version compatibility. This is a fork of phpcompatibility/php-compatibility",
+ "homepage": "http://techblog.wimgodden.be/tag/codesniffer/",
+ "keywords": [
+ "compatibility",
+ "phpcs",
+ "standards",
+ "static analysis"
+ ],
+ "support": {
+ "issues": "https://github.com/PHPCompatibility/PHPCompatibility/issues",
+ "source": "https://github.com/PHPCompatibility/PHPCompatibility"
+ },
+ "time": "2023-11-29T22:34:17+00:00"
+ },
+ {
+ "name": "phpcsstandards/phpcsutils",
+ "version": "1.0.12",
+ "source": {
+ "type": "git",
+ "url": "https://github.com/PHPCSStandards/PHPCSUtils.git",
+ "reference": "87b233b00daf83fb70f40c9a28692be017ea7c6c"
+ },
+ "dist": {
+ "type": "zip",
+ "url": "https://api.github.com/repos/PHPCSStandards/PHPCSUtils/zipball/87b233b00daf83fb70f40c9a28692be017ea7c6c",
+ "reference": "87b233b00daf83fb70f40c9a28692be017ea7c6c",
+ "shasum": ""
+ },
+ "require": {
+ "dealerdirect/phpcodesniffer-composer-installer": "^0.4.1 || ^0.5 || ^0.6.2 || ^0.7 || ^1.0",
+ "php": ">=5.4",
+ "squizlabs/php_codesniffer": "^3.10.0 || 4.0.x-dev@dev"
+ },
+ "require-dev": {
+ "ext-filter": "*",
+ "php-parallel-lint/php-console-highlighter": "^1.0",
+ "php-parallel-lint/php-parallel-lint": "^1.3.2",
+ "phpcsstandards/phpcsdevcs": "^1.1.6",
+ "yoast/phpunit-polyfills": "^1.1.0 || ^2.0.0"
+ },
+ "type": "phpcodesniffer-standard",
+ "extra": {
+ "branch-alias": {
+ "dev-stable": "1.x-dev",
+ "dev-develop": "1.x-dev"
+ }
+ },
+ "autoload": {
+ "classmap": [
+ "PHPCSUtils/"
+ ]
+ },
+ "notification-url": "https://packagist.org/downloads/",
+ "license": [
+ "LGPL-3.0-or-later"
+ ],
+ "authors": [
+ {
+ "name": "Juliette Reinders Folmer",
+ "homepage": "https://github.com/jrfnl",
+ "role": "lead"
+ },
+ {
+ "name": "Contributors",
+ "homepage": "https://github.com/PHPCSStandards/PHPCSUtils/graphs/contributors"
+ }
+ ],
+ "description": "A suite of utility functions for use with PHP_CodeSniffer",
+ "homepage": "https://phpcsutils.com/",
+ "keywords": [
+ "PHP_CodeSniffer",
+ "phpcbf",
+ "phpcodesniffer-standard",
+ "phpcs",
+ "phpcs3",
+ "standards",
+ "static analysis",
+ "tokens",
+ "utility"
+ ],
+ "support": {
+ "docs": "https://phpcsutils.com/",
+ "issues": "https://github.com/PHPCSStandards/PHPCSUtils/issues",
+ "security": "https://github.com/PHPCSStandards/PHPCSUtils/security/policy",
+ "source": "https://github.com/PHPCSStandards/PHPCSUtils"
+ },
+ "funding": [
+ {
+ "url": "https://github.com/PHPCSStandards",
+ "type": "github"
+ },
+ {
+ "url": "https://github.com/jrfnl",
+ "type": "github"
+ },
+ {
+ "url": "https://opencollective.com/php_codesniffer",
+ "type": "open_collective"
+ }
+ ],
+ "time": "2024-05-20T13:34:27+00:00"
+ },
+ {
+ "name": "phpstan/phpstan",
+ "version": "1.11.11",
+ "source": {
+ "type": "git",
+ "url": "https://github.com/phpstan/phpstan.git",
+ "reference": "707c2aed5d8d0075666e673a5e71440c1d01a5a3"
+ },
+ "dist": {
+ "type": "zip",
+ "url": "https://api.github.com/repos/phpstan/phpstan/zipball/707c2aed5d8d0075666e673a5e71440c1d01a5a3",
+ "reference": "707c2aed5d8d0075666e673a5e71440c1d01a5a3",
+ "shasum": ""
+ },
+ "require": {
+ "php": "^7.2|^8.0"
+ },
+ "conflict": {
+ "phpstan/phpstan-shim": "*"
+ },
+ "bin": [
+ "phpstan",
+ "phpstan.phar"
+ ],
+ "type": "library",
+ "autoload": {
+ "files": [
+ "bootstrap.php"
+ ]
+ },
+ "notification-url": "https://packagist.org/downloads/",
+ "license": [
+ "MIT"
+ ],
+ "description": "PHPStan - PHP Static Analysis Tool",
+ "keywords": [
+ "dev",
+ "static analysis"
+ ],
+ "support": {
+ "docs": "https://phpstan.org/user-guide/getting-started",
+ "forum": "https://github.com/phpstan/phpstan/discussions",
+ "issues": "https://github.com/phpstan/phpstan/issues",
+ "security": "https://github.com/phpstan/phpstan/security/policy",
+ "source": "https://github.com/phpstan/phpstan-src"
+ },
+ "funding": [
+ {
+ "url": "https://github.com/ondrejmirtes",
+ "type": "github"
+ },
+ {
+ "url": "https://github.com/phpstan",
+ "type": "github"
+ }
+ ],
+ "time": "2024-08-19T14:37:29+00:00"
+ },
+ {
+ "name": "psr/container",
+ "version": "2.0.2",
+ "source": {
+ "type": "git",
+ "url": "https://github.com/php-fig/container.git",
+ "reference": "c71ecc56dfe541dbd90c5360474fbc405f8d5963"
+ },
+ "dist": {
+ "type": "zip",
+ "url": "https://api.github.com/repos/php-fig/container/zipball/c71ecc56dfe541dbd90c5360474fbc405f8d5963",
+ "reference": "c71ecc56dfe541dbd90c5360474fbc405f8d5963",
+ "shasum": ""
+ },
+ "require": {
+ "php": ">=7.4.0"
+ },
+ "type": "library",
+ "extra": {
+ "branch-alias": {
+ "dev-master": "2.0.x-dev"
+ }
+ },
+ "autoload": {
+ "psr-4": {
+ "Psr\\Container\\": "src/"
+ }
+ },
+ "notification-url": "https://packagist.org/downloads/",
+ "license": [
+ "MIT"
+ ],
+ "authors": [
+ {
+ "name": "PHP-FIG",
+ "homepage": "https://www.php-fig.org/"
+ }
+ ],
+ "description": "Common Container Interface (PHP FIG PSR-11)",
+ "homepage": "https://github.com/php-fig/container",
+ "keywords": [
+ "PSR-11",
+ "container",
+ "container-interface",
+ "container-interop",
+ "psr"
+ ],
+ "support": {
+ "issues": "https://github.com/php-fig/container/issues",
+ "source": "https://github.com/php-fig/container/tree/2.0.2"
+ },
+ "time": "2021-11-05T16:47:00+00:00"
+ },
+ {
+ "name": "psr/event-dispatcher",
+ "version": "1.0.0",
+ "source": {
+ "type": "git",
+ "url": "https://github.com/php-fig/event-dispatcher.git",
+ "reference": "dbefd12671e8a14ec7f180cab83036ed26714bb0"
+ },
+ "dist": {
+ "type": "zip",
+ "url": "https://api.github.com/repos/php-fig/event-dispatcher/zipball/dbefd12671e8a14ec7f180cab83036ed26714bb0",
+ "reference": "dbefd12671e8a14ec7f180cab83036ed26714bb0",
+ "shasum": ""
+ },
+ "require": {
+ "php": ">=7.2.0"
+ },
+ "type": "library",
+ "extra": {
+ "branch-alias": {
+ "dev-master": "1.0.x-dev"
+ }
+ },
+ "autoload": {
+ "psr-4": {
+ "Psr\\EventDispatcher\\": "src/"
+ }
+ },
+ "notification-url": "https://packagist.org/downloads/",
+ "license": [
+ "MIT"
+ ],
+ "authors": [
+ {
+ "name": "PHP-FIG",
+ "homepage": "http://www.php-fig.org/"
+ }
+ ],
+ "description": "Standard interfaces for event handling.",
+ "keywords": [
+ "events",
+ "psr",
+ "psr-14"
+ ],
+ "support": {
+ "issues": "https://github.com/php-fig/event-dispatcher/issues",
+ "source": "https://github.com/php-fig/event-dispatcher/tree/1.0.0"
+ },
+ "time": "2019-01-08T18:20:26+00:00"
+ },
+ {
+ "name": "psr/log",
+ "version": "3.0.0",
+ "source": {
+ "type": "git",
+ "url": "https://github.com/php-fig/log.git",
+ "reference": "fe5ea303b0887d5caefd3d431c3e61ad47037001"
+ },
+ "dist": {
+ "type": "zip",
+ "url": "https://api.github.com/repos/php-fig/log/zipball/fe5ea303b0887d5caefd3d431c3e61ad47037001",
+ "reference": "fe5ea303b0887d5caefd3d431c3e61ad47037001",
+ "shasum": ""
+ },
+ "require": {
+ "php": ">=8.0.0"
+ },
+ "type": "library",
+ "extra": {
+ "branch-alias": {
+ "dev-master": "3.x-dev"
+ }
+ },
+ "autoload": {
+ "psr-4": {
+ "Psr\\Log\\": "src"
+ }
+ },
+ "notification-url": "https://packagist.org/downloads/",
+ "license": [
+ "MIT"
+ ],
+ "authors": [
+ {
+ "name": "PHP-FIG",
+ "homepage": "https://www.php-fig.org/"
+ }
+ ],
+ "description": "Common interface for logging libraries",
+ "homepage": "https://github.com/php-fig/log",
+ "keywords": [
+ "log",
+ "psr",
+ "psr-3"
+ ],
+ "support": {
+ "source": "https://github.com/php-fig/log/tree/3.0.0"
+ },
+ "time": "2021-07-14T16:46:02+00:00"
+ },
+ {
+ "name": "react/cache",
+ "version": "v1.2.0",
+ "source": {
+ "type": "git",
+ "url": "https://github.com/reactphp/cache.git",
+ "reference": "d47c472b64aa5608225f47965a484b75c7817d5b"
+ },
+ "dist": {
+ "type": "zip",
+ "url": "https://api.github.com/repos/reactphp/cache/zipball/d47c472b64aa5608225f47965a484b75c7817d5b",
+ "reference": "d47c472b64aa5608225f47965a484b75c7817d5b",
+ "shasum": ""
+ },
+ "require": {
+ "php": ">=5.3.0",
+ "react/promise": "^3.0 || ^2.0 || ^1.1"
+ },
+ "require-dev": {
+ "phpunit/phpunit": "^9.5 || ^5.7 || ^4.8.35"
+ },
+ "type": "library",
+ "autoload": {
+ "psr-4": {
+ "React\\Cache\\": "src/"
+ }
+ },
+ "notification-url": "https://packagist.org/downloads/",
+ "license": [
+ "MIT"
+ ],
+ "authors": [
+ {
+ "name": "Christian Lück",
+ "email": "christian@clue.engineering",
+ "homepage": "https://clue.engineering/"
+ },
+ {
+ "name": "Cees-Jan Kiewiet",
+ "email": "reactphp@ceesjankiewiet.nl",
+ "homepage": "https://wyrihaximus.net/"
+ },
+ {
+ "name": "Jan Sorgalla",
+ "email": "jsorgalla@gmail.com",
+ "homepage": "https://sorgalla.com/"
+ },
+ {
+ "name": "Chris Boden",
+ "email": "cboden@gmail.com",
+ "homepage": "https://cboden.dev/"
+ }
+ ],
+ "description": "Async, Promise-based cache interface for ReactPHP",
+ "keywords": [
+ "cache",
+ "caching",
+ "promise",
+ "reactphp"
+ ],
+ "support": {
+ "issues": "https://github.com/reactphp/cache/issues",
+ "source": "https://github.com/reactphp/cache/tree/v1.2.0"
+ },
+ "funding": [
+ {
+ "url": "https://opencollective.com/reactphp",
+ "type": "open_collective"
+ }
+ ],
+ "time": "2022-11-30T15:59:55+00:00"
+ },
+ {
+ "name": "react/child-process",
+ "version": "v0.6.5",
+ "source": {
+ "type": "git",
+ "url": "https://github.com/reactphp/child-process.git",
+ "reference": "e71eb1aa55f057c7a4a0d08d06b0b0a484bead43"
+ },
+ "dist": {
+ "type": "zip",
+ "url": "https://api.github.com/repos/reactphp/child-process/zipball/e71eb1aa55f057c7a4a0d08d06b0b0a484bead43",
+ "reference": "e71eb1aa55f057c7a4a0d08d06b0b0a484bead43",
+ "shasum": ""
+ },
+ "require": {
+ "evenement/evenement": "^3.0 || ^2.0 || ^1.0",
+ "php": ">=5.3.0",
+ "react/event-loop": "^1.2",
+ "react/stream": "^1.2"
+ },
+ "require-dev": {
+ "phpunit/phpunit": "^9.3 || ^5.7 || ^4.8.35",
+ "react/socket": "^1.8",
+ "sebastian/environment": "^5.0 || ^3.0 || ^2.0 || ^1.0"
+ },
+ "type": "library",
+ "autoload": {
+ "psr-4": {
+ "React\\ChildProcess\\": "src"
+ }
+ },
+ "notification-url": "https://packagist.org/downloads/",
+ "license": [
+ "MIT"
+ ],
+ "authors": [
+ {
+ "name": "Christian Lück",
+ "email": "christian@clue.engineering",
+ "homepage": "https://clue.engineering/"
+ },
+ {
+ "name": "Cees-Jan Kiewiet",
+ "email": "reactphp@ceesjankiewiet.nl",
+ "homepage": "https://wyrihaximus.net/"
+ },
+ {
+ "name": "Jan Sorgalla",
+ "email": "jsorgalla@gmail.com",
+ "homepage": "https://sorgalla.com/"
+ },
+ {
+ "name": "Chris Boden",
+ "email": "cboden@gmail.com",
+ "homepage": "https://cboden.dev/"
+ }
+ ],
+ "description": "Event-driven library for executing child processes with ReactPHP.",
+ "keywords": [
+ "event-driven",
+ "process",
+ "reactphp"
+ ],
+ "support": {
+ "issues": "https://github.com/reactphp/child-process/issues",
+ "source": "https://github.com/reactphp/child-process/tree/v0.6.5"
+ },
+ "funding": [
+ {
+ "url": "https://github.com/WyriHaximus",
+ "type": "github"
+ },
+ {
+ "url": "https://github.com/clue",
+ "type": "github"
+ }
+ ],
+ "time": "2022-09-16T13:41:56+00:00"
+ },
+ {
+ "name": "react/dns",
+ "version": "v1.13.0",
+ "source": {
+ "type": "git",
+ "url": "https://github.com/reactphp/dns.git",
+ "reference": "eb8ae001b5a455665c89c1df97f6fb682f8fb0f5"
+ },
+ "dist": {
+ "type": "zip",
+ "url": "https://api.github.com/repos/reactphp/dns/zipball/eb8ae001b5a455665c89c1df97f6fb682f8fb0f5",
+ "reference": "eb8ae001b5a455665c89c1df97f6fb682f8fb0f5",
+ "shasum": ""
+ },
+ "require": {
+ "php": ">=5.3.0",
+ "react/cache": "^1.0 || ^0.6 || ^0.5",
+ "react/event-loop": "^1.2",
+ "react/promise": "^3.2 || ^2.7 || ^1.2.1"
+ },
+ "require-dev": {
+ "phpunit/phpunit": "^9.6 || ^5.7 || ^4.8.36",
+ "react/async": "^4.3 || ^3 || ^2",
+ "react/promise-timer": "^1.11"
+ },
+ "type": "library",
+ "autoload": {
+ "psr-4": {
+ "React\\Dns\\": "src/"
+ }
+ },
+ "notification-url": "https://packagist.org/downloads/",
+ "license": [
+ "MIT"
+ ],
+ "authors": [
+ {
+ "name": "Christian Lück",
+ "email": "christian@clue.engineering",
+ "homepage": "https://clue.engineering/"
+ },
+ {
+ "name": "Cees-Jan Kiewiet",
+ "email": "reactphp@ceesjankiewiet.nl",
+ "homepage": "https://wyrihaximus.net/"
+ },
+ {
+ "name": "Jan Sorgalla",
+ "email": "jsorgalla@gmail.com",
+ "homepage": "https://sorgalla.com/"
+ },
+ {
+ "name": "Chris Boden",
+ "email": "cboden@gmail.com",
+ "homepage": "https://cboden.dev/"
+ }
+ ],
+ "description": "Async DNS resolver for ReactPHP",
+ "keywords": [
+ "async",
+ "dns",
+ "dns-resolver",
+ "reactphp"
+ ],
+ "support": {
+ "issues": "https://github.com/reactphp/dns/issues",
+ "source": "https://github.com/reactphp/dns/tree/v1.13.0"
+ },
+ "funding": [
+ {
+ "url": "https://opencollective.com/reactphp",
+ "type": "open_collective"
+ }
+ ],
+ "time": "2024-06-13T14:18:03+00:00"
+ },
+ {
+ "name": "react/event-loop",
+ "version": "v1.5.0",
+ "source": {
+ "type": "git",
+ "url": "https://github.com/reactphp/event-loop.git",
+ "reference": "bbe0bd8c51ffc05ee43f1729087ed3bdf7d53354"
+ },
+ "dist": {
+ "type": "zip",
+ "url": "https://api.github.com/repos/reactphp/event-loop/zipball/bbe0bd8c51ffc05ee43f1729087ed3bdf7d53354",
+ "reference": "bbe0bd8c51ffc05ee43f1729087ed3bdf7d53354",
+ "shasum": ""
+ },
+ "require": {
+ "php": ">=5.3.0"
+ },
+ "require-dev": {
+ "phpunit/phpunit": "^9.6 || ^5.7 || ^4.8.36"
+ },
+ "suggest": {
+ "ext-pcntl": "For signal handling support when using the StreamSelectLoop"
+ },
+ "type": "library",
+ "autoload": {
+ "psr-4": {
+ "React\\EventLoop\\": "src/"
+ }
+ },
+ "notification-url": "https://packagist.org/downloads/",
+ "license": [
+ "MIT"
+ ],
+ "authors": [
+ {
+ "name": "Christian Lück",
+ "email": "christian@clue.engineering",
+ "homepage": "https://clue.engineering/"
+ },
+ {
+ "name": "Cees-Jan Kiewiet",
+ "email": "reactphp@ceesjankiewiet.nl",
+ "homepage": "https://wyrihaximus.net/"
+ },
+ {
+ "name": "Jan Sorgalla",
+ "email": "jsorgalla@gmail.com",
+ "homepage": "https://sorgalla.com/"
+ },
+ {
+ "name": "Chris Boden",
+ "email": "cboden@gmail.com",
+ "homepage": "https://cboden.dev/"
+ }
+ ],
+ "description": "ReactPHP's core reactor event loop that libraries can use for evented I/O.",
+ "keywords": [
+ "asynchronous",
+ "event-loop"
+ ],
+ "support": {
+ "issues": "https://github.com/reactphp/event-loop/issues",
+ "source": "https://github.com/reactphp/event-loop/tree/v1.5.0"
+ },
+ "funding": [
+ {
+ "url": "https://opencollective.com/reactphp",
+ "type": "open_collective"
+ }
+ ],
+ "time": "2023-11-13T13:48:05+00:00"
+ },
+ {
+ "name": "react/promise",
+ "version": "v3.2.0",
+ "source": {
+ "type": "git",
+ "url": "https://github.com/reactphp/promise.git",
+ "reference": "8a164643313c71354582dc850b42b33fa12a4b63"
+ },
+ "dist": {
+ "type": "zip",
+ "url": "https://api.github.com/repos/reactphp/promise/zipball/8a164643313c71354582dc850b42b33fa12a4b63",
+ "reference": "8a164643313c71354582dc850b42b33fa12a4b63",
+ "shasum": ""
+ },
+ "require": {
+ "php": ">=7.1.0"
+ },
+ "require-dev": {
+ "phpstan/phpstan": "1.10.39 || 1.4.10",
+ "phpunit/phpunit": "^9.6 || ^7.5"
+ },
+ "type": "library",
+ "autoload": {
+ "files": [
+ "src/functions_include.php"
+ ],
+ "psr-4": {
+ "React\\Promise\\": "src/"
+ }
+ },
+ "notification-url": "https://packagist.org/downloads/",
+ "license": [
+ "MIT"
+ ],
+ "authors": [
+ {
+ "name": "Jan Sorgalla",
+ "email": "jsorgalla@gmail.com",
+ "homepage": "https://sorgalla.com/"
+ },
+ {
+ "name": "Christian Lück",
+ "email": "christian@clue.engineering",
+ "homepage": "https://clue.engineering/"
+ },
+ {
+ "name": "Cees-Jan Kiewiet",
+ "email": "reactphp@ceesjankiewiet.nl",
+ "homepage": "https://wyrihaximus.net/"
+ },
+ {
+ "name": "Chris Boden",
+ "email": "cboden@gmail.com",
+ "homepage": "https://cboden.dev/"
+ }
+ ],
+ "description": "A lightweight implementation of CommonJS Promises/A for PHP",
+ "keywords": [
+ "promise",
+ "promises"
+ ],
+ "support": {
+ "issues": "https://github.com/reactphp/promise/issues",
+ "source": "https://github.com/reactphp/promise/tree/v3.2.0"
+ },
+ "funding": [
+ {
+ "url": "https://opencollective.com/reactphp",
+ "type": "open_collective"
+ }
+ ],
+ "time": "2024-05-24T10:39:05+00:00"
+ },
+ {
+ "name": "react/socket",
+ "version": "v1.16.0",
+ "source": {
+ "type": "git",
+ "url": "https://github.com/reactphp/socket.git",
+ "reference": "23e4ff33ea3e160d2d1f59a0e6050e4b0fb0eac1"
+ },
+ "dist": {
+ "type": "zip",
+ "url": "https://api.github.com/repos/reactphp/socket/zipball/23e4ff33ea3e160d2d1f59a0e6050e4b0fb0eac1",
+ "reference": "23e4ff33ea3e160d2d1f59a0e6050e4b0fb0eac1",
+ "shasum": ""
+ },
+ "require": {
+ "evenement/evenement": "^3.0 || ^2.0 || ^1.0",
+ "php": ">=5.3.0",
+ "react/dns": "^1.13",
+ "react/event-loop": "^1.2",
+ "react/promise": "^3.2 || ^2.6 || ^1.2.1",
+ "react/stream": "^1.4"
+ },
+ "require-dev": {
+ "phpunit/phpunit": "^9.6 || ^5.7 || ^4.8.36",
+ "react/async": "^4.3 || ^3.3 || ^2",
+ "react/promise-stream": "^1.4",
+ "react/promise-timer": "^1.11"
+ },
+ "type": "library",
+ "autoload": {
+ "psr-4": {
+ "React\\Socket\\": "src/"
+ }
+ },
+ "notification-url": "https://packagist.org/downloads/",
+ "license": [
+ "MIT"
+ ],
+ "authors": [
+ {
+ "name": "Christian Lück",
+ "email": "christian@clue.engineering",
+ "homepage": "https://clue.engineering/"
+ },
+ {
+ "name": "Cees-Jan Kiewiet",
+ "email": "reactphp@ceesjankiewiet.nl",
+ "homepage": "https://wyrihaximus.net/"
+ },
+ {
+ "name": "Jan Sorgalla",
+ "email": "jsorgalla@gmail.com",
+ "homepage": "https://sorgalla.com/"
+ },
+ {
+ "name": "Chris Boden",
+ "email": "cboden@gmail.com",
+ "homepage": "https://cboden.dev/"
+ }
+ ],
+ "description": "Async, streaming plaintext TCP/IP and secure TLS socket server and client connections for ReactPHP",
+ "keywords": [
+ "Connection",
+ "Socket",
+ "async",
+ "reactphp",
+ "stream"
+ ],
+ "support": {
+ "issues": "https://github.com/reactphp/socket/issues",
+ "source": "https://github.com/reactphp/socket/tree/v1.16.0"
+ },
+ "funding": [
+ {
+ "url": "https://opencollective.com/reactphp",
+ "type": "open_collective"
+ }
+ ],
+ "time": "2024-07-26T10:38:09+00:00"
+ },
+ {
+ "name": "react/stream",
+ "version": "v1.4.0",
+ "source": {
+ "type": "git",
+ "url": "https://github.com/reactphp/stream.git",
+ "reference": "1e5b0acb8fe55143b5b426817155190eb6f5b18d"
+ },
+ "dist": {
+ "type": "zip",
+ "url": "https://api.github.com/repos/reactphp/stream/zipball/1e5b0acb8fe55143b5b426817155190eb6f5b18d",
+ "reference": "1e5b0acb8fe55143b5b426817155190eb6f5b18d",
+ "shasum": ""
+ },
+ "require": {
+ "evenement/evenement": "^3.0 || ^2.0 || ^1.0",
+ "php": ">=5.3.8",
+ "react/event-loop": "^1.2"
+ },
+ "require-dev": {
+ "clue/stream-filter": "~1.2",
+ "phpunit/phpunit": "^9.6 || ^5.7 || ^4.8.36"
+ },
+ "type": "library",
+ "autoload": {
+ "psr-4": {
+ "React\\Stream\\": "src/"
+ }
+ },
+ "notification-url": "https://packagist.org/downloads/",
+ "license": [
+ "MIT"
+ ],
+ "authors": [
+ {
+ "name": "Christian Lück",
+ "email": "christian@clue.engineering",
+ "homepage": "https://clue.engineering/"
+ },
+ {
+ "name": "Cees-Jan Kiewiet",
+ "email": "reactphp@ceesjankiewiet.nl",
+ "homepage": "https://wyrihaximus.net/"
+ },
+ {
+ "name": "Jan Sorgalla",
+ "email": "jsorgalla@gmail.com",
+ "homepage": "https://sorgalla.com/"
+ },
+ {
+ "name": "Chris Boden",
+ "email": "cboden@gmail.com",
+ "homepage": "https://cboden.dev/"
+ }
+ ],
+ "description": "Event-driven readable and writable streams for non-blocking I/O in ReactPHP",
+ "keywords": [
+ "event-driven",
+ "io",
+ "non-blocking",
+ "pipe",
+ "reactphp",
+ "readable",
+ "stream",
+ "writable"
+ ],
+ "support": {
+ "issues": "https://github.com/reactphp/stream/issues",
+ "source": "https://github.com/reactphp/stream/tree/v1.4.0"
+ },
+ "funding": [
+ {
+ "url": "https://opencollective.com/reactphp",
+ "type": "open_collective"
+ }
+ ],
+ "time": "2024-06-11T12:45:25+00:00"
+ },
+ {
+ "name": "rector/rector",
+ "version": "0.17.13",
+ "source": {
+ "type": "git",
+ "url": "https://github.com/rectorphp/rector.git",
+ "reference": "e2003ba7c5bda06d7bb419cf4be8dae5f8672132"
+ },
+ "dist": {
+ "type": "zip",
+ "url": "https://api.github.com/repos/rectorphp/rector/zipball/e2003ba7c5bda06d7bb419cf4be8dae5f8672132",
+ "reference": "e2003ba7c5bda06d7bb419cf4be8dae5f8672132",
+ "shasum": ""
+ },
+ "require": {
+ "php": "^7.2|^8.0",
+ "phpstan/phpstan": "^1.10.26"
+ },
+ "conflict": {
+ "rector/rector-doctrine": "*",
+ "rector/rector-downgrade-php": "*",
+ "rector/rector-phpunit": "*",
+ "rector/rector-symfony": "*"
+ },
+ "bin": [
+ "bin/rector"
+ ],
+ "type": "library",
+ "autoload": {
+ "files": [
+ "bootstrap.php"
+ ]
+ },
+ "notification-url": "https://packagist.org/downloads/",
+ "license": [
+ "MIT"
+ ],
+ "description": "Instant Upgrade and Automated Refactoring of any PHP code",
+ "keywords": [
+ "automation",
+ "dev",
+ "migration",
+ "refactoring"
+ ],
+ "support": {
+ "issues": "https://github.com/rectorphp/rector/issues",
+ "source": "https://github.com/rectorphp/rector/tree/0.17.13"
+ },
+ "funding": [
+ {
+ "url": "https://github.com/tomasvotruba",
+ "type": "github"
+ }
+ ],
+ "time": "2023-08-14T16:33:29+00:00"
+ },
+ {
+ "name": "sebastian/diff",
+ "version": "5.1.1",
+ "source": {
+ "type": "git",
+ "url": "https://github.com/sebastianbergmann/diff.git",
+ "reference": "c41e007b4b62af48218231d6c2275e4c9b975b2e"
+ },
+ "dist": {
+ "type": "zip",
+ "url": "https://api.github.com/repos/sebastianbergmann/diff/zipball/c41e007b4b62af48218231d6c2275e4c9b975b2e",
+ "reference": "c41e007b4b62af48218231d6c2275e4c9b975b2e",
+ "shasum": ""
+ },
+ "require": {
+ "php": ">=8.1"
+ },
+ "require-dev": {
+ "phpunit/phpunit": "^10.0",
+ "symfony/process": "^6.4"
+ },
+ "type": "library",
+ "extra": {
+ "branch-alias": {
+ "dev-main": "5.1-dev"
+ }
+ },
+ "autoload": {
+ "classmap": [
+ "src/"
+ ]
+ },
+ "notification-url": "https://packagist.org/downloads/",
+ "license": [
+ "BSD-3-Clause"
+ ],
+ "authors": [
+ {
+ "name": "Sebastian Bergmann",
+ "email": "sebastian@phpunit.de"
+ },
+ {
+ "name": "Kore Nordmann",
+ "email": "mail@kore-nordmann.de"
+ }
+ ],
+ "description": "Diff implementation",
+ "homepage": "https://github.com/sebastianbergmann/diff",
+ "keywords": [
+ "diff",
+ "udiff",
+ "unidiff",
+ "unified diff"
+ ],
+ "support": {
+ "issues": "https://github.com/sebastianbergmann/diff/issues",
+ "security": "https://github.com/sebastianbergmann/diff/security/policy",
+ "source": "https://github.com/sebastianbergmann/diff/tree/5.1.1"
+ },
+ "funding": [
+ {
+ "url": "https://github.com/sebastianbergmann",
+ "type": "github"
+ }
+ ],
+ "time": "2024-03-02T07:15:17+00:00"
+ },
+ {
+ "name": "squizlabs/php_codesniffer",
+ "version": "3.10.2",
+ "source": {
+ "type": "git",
+ "url": "https://github.com/PHPCSStandards/PHP_CodeSniffer.git",
+ "reference": "86e5f5dd9a840c46810ebe5ff1885581c42a3017"
+ },
+ "dist": {
+ "type": "zip",
+ "url": "https://api.github.com/repos/PHPCSStandards/PHP_CodeSniffer/zipball/86e5f5dd9a840c46810ebe5ff1885581c42a3017",
+ "reference": "86e5f5dd9a840c46810ebe5ff1885581c42a3017",
+ "shasum": ""
+ },
+ "require": {
+ "ext-simplexml": "*",
+ "ext-tokenizer": "*",
+ "ext-xmlwriter": "*",
+ "php": ">=5.4.0"
+ },
+ "require-dev": {
+ "phpunit/phpunit": "^4.0 || ^5.0 || ^6.0 || ^7.0 || ^8.0 || ^9.3.4"
+ },
+ "bin": [
+ "bin/phpcbf",
+ "bin/phpcs"
+ ],
+ "type": "library",
+ "extra": {
+ "branch-alias": {
+ "dev-master": "3.x-dev"
+ }
+ },
+ "notification-url": "https://packagist.org/downloads/",
+ "license": [
+ "BSD-3-Clause"
+ ],
+ "authors": [
+ {
+ "name": "Greg Sherwood",
+ "role": "Former lead"
+ },
+ {
+ "name": "Juliette Reinders Folmer",
+ "role": "Current lead"
+ },
+ {
+ "name": "Contributors",
+ "homepage": "https://github.com/PHPCSStandards/PHP_CodeSniffer/graphs/contributors"
+ }
+ ],
+ "description": "PHP_CodeSniffer tokenizes PHP, JavaScript and CSS files and detects violations of a defined set of coding standards.",
+ "homepage": "https://github.com/PHPCSStandards/PHP_CodeSniffer",
+ "keywords": [
+ "phpcs",
+ "standards",
+ "static analysis"
+ ],
+ "support": {
+ "issues": "https://github.com/PHPCSStandards/PHP_CodeSniffer/issues",
+ "security": "https://github.com/PHPCSStandards/PHP_CodeSniffer/security/policy",
+ "source": "https://github.com/PHPCSStandards/PHP_CodeSniffer",
+ "wiki": "https://github.com/PHPCSStandards/PHP_CodeSniffer/wiki"
+ },
+ "funding": [
+ {
+ "url": "https://github.com/PHPCSStandards",
+ "type": "github"
+ },
+ {
+ "url": "https://github.com/jrfnl",
+ "type": "github"
+ },
+ {
+ "url": "https://opencollective.com/php_codesniffer",
+ "type": "open_collective"
+ }
+ ],
+ "time": "2024-07-21T23:26:44+00:00"
+ },
+ {
+ "name": "symfony/console",
+ "version": "v6.4.10",
+ "source": {
+ "type": "git",
+ "url": "https://github.com/symfony/console.git",
+ "reference": "504974cbe43d05f83b201d6498c206f16fc0cdbc"
+ },
+ "dist": {
+ "type": "zip",
+ "url": "https://api.github.com/repos/symfony/console/zipball/504974cbe43d05f83b201d6498c206f16fc0cdbc",
+ "reference": "504974cbe43d05f83b201d6498c206f16fc0cdbc",
+ "shasum": ""
+ },
+ "require": {
+ "php": ">=8.1",
+ "symfony/deprecation-contracts": "^2.5|^3",
+ "symfony/polyfill-mbstring": "~1.0",
+ "symfony/service-contracts": "^2.5|^3",
+ "symfony/string": "^5.4|^6.0|^7.0"
+ },
+ "conflict": {
+ "symfony/dependency-injection": "<5.4",
+ "symfony/dotenv": "<5.4",
+ "symfony/event-dispatcher": "<5.4",
+ "symfony/lock": "<5.4",
+ "symfony/process": "<5.4"
+ },
+ "provide": {
+ "psr/log-implementation": "1.0|2.0|3.0"
+ },
+ "require-dev": {
+ "psr/log": "^1|^2|^3",
+ "symfony/config": "^5.4|^6.0|^7.0",
+ "symfony/dependency-injection": "^5.4|^6.0|^7.0",
+ "symfony/event-dispatcher": "^5.4|^6.0|^7.0",
+ "symfony/http-foundation": "^6.4|^7.0",
+ "symfony/http-kernel": "^6.4|^7.0",
+ "symfony/lock": "^5.4|^6.0|^7.0",
+ "symfony/messenger": "^5.4|^6.0|^7.0",
+ "symfony/process": "^5.4|^6.0|^7.0",
+ "symfony/stopwatch": "^5.4|^6.0|^7.0",
+ "symfony/var-dumper": "^5.4|^6.0|^7.0"
+ },
+ "type": "library",
+ "autoload": {
+ "psr-4": {
+ "Symfony\\Component\\Console\\": ""
+ },
+ "exclude-from-classmap": [
+ "/Tests/"
+ ]
+ },
+ "notification-url": "https://packagist.org/downloads/",
+ "license": [
+ "MIT"
+ ],
+ "authors": [
+ {
+ "name": "Fabien Potencier",
+ "email": "fabien@symfony.com"
+ },
+ {
+ "name": "Symfony Community",
+ "homepage": "https://symfony.com/contributors"
+ }
+ ],
+ "description": "Eases the creation of beautiful and testable command line interfaces",
+ "homepage": "https://symfony.com",
+ "keywords": [
+ "cli",
+ "command-line",
+ "console",
+ "terminal"
+ ],
+ "support": {
+ "source": "https://github.com/symfony/console/tree/v6.4.10"
+ },
+ "funding": [
+ {
+ "url": "https://symfony.com/sponsor",
+ "type": "custom"
+ },
+ {
+ "url": "https://github.com/fabpot",
+ "type": "github"
+ },
+ {
+ "url": "https://tidelift.com/funding/github/packagist/symfony/symfony",
+ "type": "tidelift"
+ }
+ ],
+ "time": "2024-07-26T12:30:32+00:00"
+ },
+ {
+ "name": "symfony/deprecation-contracts",
+ "version": "v3.5.0",
+ "source": {
+ "type": "git",
+ "url": "https://github.com/symfony/deprecation-contracts.git",
+ "reference": "0e0d29ce1f20deffb4ab1b016a7257c4f1e789a1"
+ },
+ "dist": {
+ "type": "zip",
+ "url": "https://api.github.com/repos/symfony/deprecation-contracts/zipball/0e0d29ce1f20deffb4ab1b016a7257c4f1e789a1",
+ "reference": "0e0d29ce1f20deffb4ab1b016a7257c4f1e789a1",
+ "shasum": ""
+ },
+ "require": {
+ "php": ">=8.1"
+ },
+ "type": "library",
+ "extra": {
+ "branch-alias": {
+ "dev-main": "3.5-dev"
+ },
+ "thanks": {
+ "name": "symfony/contracts",
+ "url": "https://github.com/symfony/contracts"
+ }
+ },
+ "autoload": {
+ "files": [
+ "function.php"
+ ]
+ },
+ "notification-url": "https://packagist.org/downloads/",
+ "license": [
+ "MIT"
+ ],
+ "authors": [
+ {
+ "name": "Nicolas Grekas",
+ "email": "p@tchwork.com"
+ },
+ {
+ "name": "Symfony Community",
+ "homepage": "https://symfony.com/contributors"
+ }
+ ],
+ "description": "A generic function and convention to trigger deprecation notices",
+ "homepage": "https://symfony.com",
+ "support": {
+ "source": "https://github.com/symfony/deprecation-contracts/tree/v3.5.0"
+ },
+ "funding": [
+ {
+ "url": "https://symfony.com/sponsor",
+ "type": "custom"
+ },
+ {
+ "url": "https://github.com/fabpot",
+ "type": "github"
+ },
+ {
+ "url": "https://tidelift.com/funding/github/packagist/symfony/symfony",
+ "type": "tidelift"
+ }
+ ],
+ "time": "2024-04-18T09:32:20+00:00"
+ },
+ {
+ "name": "symfony/event-dispatcher",
+ "version": "v6.4.8",
+ "source": {
+ "type": "git",
+ "url": "https://github.com/symfony/event-dispatcher.git",
+ "reference": "8d7507f02b06e06815e56bb39aa0128e3806208b"
+ },
+ "dist": {
+ "type": "zip",
+ "url": "https://api.github.com/repos/symfony/event-dispatcher/zipball/8d7507f02b06e06815e56bb39aa0128e3806208b",
+ "reference": "8d7507f02b06e06815e56bb39aa0128e3806208b",
+ "shasum": ""
+ },
+ "require": {
+ "php": ">=8.1",
+ "symfony/event-dispatcher-contracts": "^2.5|^3"
+ },
+ "conflict": {
+ "symfony/dependency-injection": "<5.4",
+ "symfony/service-contracts": "<2.5"
+ },
+ "provide": {
+ "psr/event-dispatcher-implementation": "1.0",
+ "symfony/event-dispatcher-implementation": "2.0|3.0"
+ },
+ "require-dev": {
+ "psr/log": "^1|^2|^3",
+ "symfony/config": "^5.4|^6.0|^7.0",
+ "symfony/dependency-injection": "^5.4|^6.0|^7.0",
+ "symfony/error-handler": "^5.4|^6.0|^7.0",
+ "symfony/expression-language": "^5.4|^6.0|^7.0",
+ "symfony/http-foundation": "^5.4|^6.0|^7.0",
+ "symfony/service-contracts": "^2.5|^3",
+ "symfony/stopwatch": "^5.4|^6.0|^7.0"
+ },
+ "type": "library",
+ "autoload": {
+ "psr-4": {
+ "Symfony\\Component\\EventDispatcher\\": ""
+ },
+ "exclude-from-classmap": [
+ "/Tests/"
+ ]
+ },
+ "notification-url": "https://packagist.org/downloads/",
+ "license": [
+ "MIT"
+ ],
+ "authors": [
+ {
+ "name": "Fabien Potencier",
+ "email": "fabien@symfony.com"
+ },
+ {
+ "name": "Symfony Community",
+ "homepage": "https://symfony.com/contributors"
+ }
+ ],
+ "description": "Provides tools that allow your application components to communicate with each other by dispatching events and listening to them",
+ "homepage": "https://symfony.com",
+ "support": {
+ "source": "https://github.com/symfony/event-dispatcher/tree/v6.4.8"
+ },
+ "funding": [
+ {
+ "url": "https://symfony.com/sponsor",
+ "type": "custom"
+ },
+ {
+ "url": "https://github.com/fabpot",
+ "type": "github"
+ },
+ {
+ "url": "https://tidelift.com/funding/github/packagist/symfony/symfony",
+ "type": "tidelift"
+ }
+ ],
+ "time": "2024-05-31T14:49:08+00:00"
+ },
+ {
+ "name": "symfony/event-dispatcher-contracts",
+ "version": "v3.5.0",
+ "source": {
+ "type": "git",
+ "url": "https://github.com/symfony/event-dispatcher-contracts.git",
+ "reference": "8f93aec25d41b72493c6ddff14e916177c9efc50"
+ },
+ "dist": {
+ "type": "zip",
+ "url": "https://api.github.com/repos/symfony/event-dispatcher-contracts/zipball/8f93aec25d41b72493c6ddff14e916177c9efc50",
+ "reference": "8f93aec25d41b72493c6ddff14e916177c9efc50",
+ "shasum": ""
+ },
+ "require": {
+ "php": ">=8.1",
+ "psr/event-dispatcher": "^1"
+ },
+ "type": "library",
+ "extra": {
+ "branch-alias": {
+ "dev-main": "3.5-dev"
+ },
+ "thanks": {
+ "name": "symfony/contracts",
+ "url": "https://github.com/symfony/contracts"
+ }
+ },
+ "autoload": {
+ "psr-4": {
+ "Symfony\\Contracts\\EventDispatcher\\": ""
+ }
+ },
+ "notification-url": "https://packagist.org/downloads/",
+ "license": [
+ "MIT"
+ ],
+ "authors": [
+ {
+ "name": "Nicolas Grekas",
+ "email": "p@tchwork.com"
+ },
+ {
+ "name": "Symfony Community",
+ "homepage": "https://symfony.com/contributors"
+ }
+ ],
+ "description": "Generic abstractions related to dispatching event",
+ "homepage": "https://symfony.com",
+ "keywords": [
+ "abstractions",
+ "contracts",
+ "decoupling",
+ "interfaces",
+ "interoperability",
+ "standards"
+ ],
+ "support": {
+ "source": "https://github.com/symfony/event-dispatcher-contracts/tree/v3.5.0"
+ },
+ "funding": [
+ {
+ "url": "https://symfony.com/sponsor",
+ "type": "custom"
+ },
+ {
+ "url": "https://github.com/fabpot",
+ "type": "github"
+ },
+ {
+ "url": "https://tidelift.com/funding/github/packagist/symfony/symfony",
+ "type": "tidelift"
+ }
+ ],
+ "time": "2024-04-18T09:32:20+00:00"
+ },
+ {
+ "name": "symfony/filesystem",
+ "version": "v6.4.9",
+ "source": {
+ "type": "git",
+ "url": "https://github.com/symfony/filesystem.git",
+ "reference": "b51ef8059159330b74a4d52f68e671033c0fe463"
+ },
+ "dist": {
+ "type": "zip",
+ "url": "https://api.github.com/repos/symfony/filesystem/zipball/b51ef8059159330b74a4d52f68e671033c0fe463",
+ "reference": "b51ef8059159330b74a4d52f68e671033c0fe463",
+ "shasum": ""
+ },
+ "require": {
+ "php": ">=8.1",
+ "symfony/polyfill-ctype": "~1.8",
+ "symfony/polyfill-mbstring": "~1.8"
+ },
+ "require-dev": {
+ "symfony/process": "^5.4|^6.4|^7.0"
+ },
+ "type": "library",
+ "autoload": {
+ "psr-4": {
+ "Symfony\\Component\\Filesystem\\": ""
+ },
+ "exclude-from-classmap": [
+ "/Tests/"
+ ]
+ },
+ "notification-url": "https://packagist.org/downloads/",
+ "license": [
+ "MIT"
+ ],
+ "authors": [
+ {
+ "name": "Fabien Potencier",
+ "email": "fabien@symfony.com"
+ },
+ {
+ "name": "Symfony Community",
+ "homepage": "https://symfony.com/contributors"
+ }
+ ],
+ "description": "Provides basic utilities for the filesystem",
+ "homepage": "https://symfony.com",
+ "support": {
+ "source": "https://github.com/symfony/filesystem/tree/v6.4.9"
+ },
+ "funding": [
+ {
+ "url": "https://symfony.com/sponsor",
+ "type": "custom"
+ },
+ {
+ "url": "https://github.com/fabpot",
+ "type": "github"
+ },
+ {
+ "url": "https://tidelift.com/funding/github/packagist/symfony/symfony",
+ "type": "tidelift"
+ }
+ ],
+ "time": "2024-06-28T09:49:33+00:00"
+ },
+ {
+ "name": "symfony/finder",
+ "version": "v6.4.10",
+ "source": {
+ "type": "git",
+ "url": "https://github.com/symfony/finder.git",
+ "reference": "af29198d87112bebdd397bd7735fbd115997824c"
+ },
+ "dist": {
+ "type": "zip",
+ "url": "https://api.github.com/repos/symfony/finder/zipball/af29198d87112bebdd397bd7735fbd115997824c",
+ "reference": "af29198d87112bebdd397bd7735fbd115997824c",
+ "shasum": ""
+ },
+ "require": {
+ "php": ">=8.1"
+ },
+ "require-dev": {
+ "symfony/filesystem": "^6.0|^7.0"
+ },
+ "type": "library",
+ "autoload": {
+ "psr-4": {
+ "Symfony\\Component\\Finder\\": ""
+ },
+ "exclude-from-classmap": [
+ "/Tests/"
+ ]
+ },
+ "notification-url": "https://packagist.org/downloads/",
+ "license": [
+ "MIT"
+ ],
+ "authors": [
+ {
+ "name": "Fabien Potencier",
+ "email": "fabien@symfony.com"
+ },
+ {
+ "name": "Symfony Community",
+ "homepage": "https://symfony.com/contributors"
+ }
+ ],
+ "description": "Finds files and directories via an intuitive fluent interface",
+ "homepage": "https://symfony.com",
+ "support": {
+ "source": "https://github.com/symfony/finder/tree/v6.4.10"
+ },
+ "funding": [
+ {
+ "url": "https://symfony.com/sponsor",
+ "type": "custom"
+ },
+ {
+ "url": "https://github.com/fabpot",
+ "type": "github"
+ },
+ {
+ "url": "https://tidelift.com/funding/github/packagist/symfony/symfony",
+ "type": "tidelift"
+ }
+ ],
+ "time": "2024-07-24T07:06:38+00:00"
+ },
+ {
+ "name": "symfony/options-resolver",
+ "version": "v6.4.8",
+ "source": {
+ "type": "git",
+ "url": "https://github.com/symfony/options-resolver.git",
+ "reference": "22ab9e9101ab18de37839074f8a1197f55590c1b"
+ },
+ "dist": {
+ "type": "zip",
+ "url": "https://api.github.com/repos/symfony/options-resolver/zipball/22ab9e9101ab18de37839074f8a1197f55590c1b",
+ "reference": "22ab9e9101ab18de37839074f8a1197f55590c1b",
+ "shasum": ""
+ },
+ "require": {
+ "php": ">=8.1",
+ "symfony/deprecation-contracts": "^2.5|^3"
+ },
+ "type": "library",
+ "autoload": {
+ "psr-4": {
+ "Symfony\\Component\\OptionsResolver\\": ""
+ },
+ "exclude-from-classmap": [
+ "/Tests/"
+ ]
+ },
+ "notification-url": "https://packagist.org/downloads/",
+ "license": [
+ "MIT"
+ ],
+ "authors": [
+ {
+ "name": "Fabien Potencier",
+ "email": "fabien@symfony.com"
+ },
+ {
+ "name": "Symfony Community",
+ "homepage": "https://symfony.com/contributors"
+ }
+ ],
+ "description": "Provides an improved replacement for the array_replace PHP function",
+ "homepage": "https://symfony.com",
+ "keywords": [
+ "config",
+ "configuration",
+ "options"
+ ],
+ "support": {
+ "source": "https://github.com/symfony/options-resolver/tree/v6.4.8"
+ },
+ "funding": [
+ {
+ "url": "https://symfony.com/sponsor",
+ "type": "custom"
+ },
+ {
+ "url": "https://github.com/fabpot",
+ "type": "github"
+ },
+ {
+ "url": "https://tidelift.com/funding/github/packagist/symfony/symfony",
+ "type": "tidelift"
+ }
+ ],
+ "time": "2024-05-31T14:49:08+00:00"
+ },
+ {
+ "name": "symfony/polyfill-ctype",
+ "version": "v1.30.0",
+ "source": {
+ "type": "git",
+ "url": "https://github.com/symfony/polyfill-ctype.git",
+ "reference": "0424dff1c58f028c451efff2045f5d92410bd540"
+ },
+ "dist": {
+ "type": "zip",
+ "url": "https://api.github.com/repos/symfony/polyfill-ctype/zipball/0424dff1c58f028c451efff2045f5d92410bd540",
+ "reference": "0424dff1c58f028c451efff2045f5d92410bd540",
+ "shasum": ""
+ },
+ "require": {
+ "php": ">=7.1"
+ },
+ "provide": {
+ "ext-ctype": "*"
+ },
+ "suggest": {
+ "ext-ctype": "For best performance"
+ },
+ "type": "library",
+ "extra": {
+ "thanks": {
+ "name": "symfony/polyfill",
+ "url": "https://github.com/symfony/polyfill"
+ }
+ },
+ "autoload": {
+ "files": [
+ "bootstrap.php"
+ ],
+ "psr-4": {
+ "Symfony\\Polyfill\\Ctype\\": ""
+ }
+ },
+ "notification-url": "https://packagist.org/downloads/",
+ "license": [
+ "MIT"
+ ],
+ "authors": [
+ {
+ "name": "Gert de Pagter",
+ "email": "BackEndTea@gmail.com"
+ },
+ {
+ "name": "Symfony Community",
+ "homepage": "https://symfony.com/contributors"
+ }
+ ],
+ "description": "Symfony polyfill for ctype functions",
+ "homepage": "https://symfony.com",
+ "keywords": [
+ "compatibility",
+ "ctype",
+ "polyfill",
+ "portable"
+ ],
+ "support": {
+ "source": "https://github.com/symfony/polyfill-ctype/tree/v1.30.0"
+ },
+ "funding": [
+ {
+ "url": "https://symfony.com/sponsor",
+ "type": "custom"
+ },
+ {
+ "url": "https://github.com/fabpot",
+ "type": "github"
+ },
+ {
+ "url": "https://tidelift.com/funding/github/packagist/symfony/symfony",
+ "type": "tidelift"
+ }
+ ],
+ "time": "2024-05-31T15:07:36+00:00"
+ },
+ {
+ "name": "symfony/polyfill-intl-grapheme",
+ "version": "v1.30.0",
+ "source": {
+ "type": "git",
+ "url": "https://github.com/symfony/polyfill-intl-grapheme.git",
+ "reference": "64647a7c30b2283f5d49b874d84a18fc22054b7a"
+ },
+ "dist": {
+ "type": "zip",
+ "url": "https://api.github.com/repos/symfony/polyfill-intl-grapheme/zipball/64647a7c30b2283f5d49b874d84a18fc22054b7a",
+ "reference": "64647a7c30b2283f5d49b874d84a18fc22054b7a",
+ "shasum": ""
+ },
+ "require": {
+ "php": ">=7.1"
+ },
+ "suggest": {
+ "ext-intl": "For best performance"
+ },
+ "type": "library",
+ "extra": {
+ "thanks": {
+ "name": "symfony/polyfill",
+ "url": "https://github.com/symfony/polyfill"
+ }
+ },
+ "autoload": {
+ "files": [
+ "bootstrap.php"
+ ],
+ "psr-4": {
+ "Symfony\\Polyfill\\Intl\\Grapheme\\": ""
+ }
+ },
+ "notification-url": "https://packagist.org/downloads/",
+ "license": [
+ "MIT"
+ ],
+ "authors": [
+ {
+ "name": "Nicolas Grekas",
+ "email": "p@tchwork.com"
+ },
+ {
+ "name": "Symfony Community",
+ "homepage": "https://symfony.com/contributors"
+ }
+ ],
+ "description": "Symfony polyfill for intl's grapheme_* functions",
+ "homepage": "https://symfony.com",
+ "keywords": [
+ "compatibility",
+ "grapheme",
+ "intl",
+ "polyfill",
+ "portable",
+ "shim"
+ ],
+ "support": {
+ "source": "https://github.com/symfony/polyfill-intl-grapheme/tree/v1.30.0"
+ },
+ "funding": [
+ {
+ "url": "https://symfony.com/sponsor",
+ "type": "custom"
+ },
+ {
+ "url": "https://github.com/fabpot",
+ "type": "github"
+ },
+ {
+ "url": "https://tidelift.com/funding/github/packagist/symfony/symfony",
+ "type": "tidelift"
+ }
+ ],
+ "time": "2024-05-31T15:07:36+00:00"
+ },
+ {
+ "name": "symfony/polyfill-intl-normalizer",
+ "version": "v1.30.0",
+ "source": {
+ "type": "git",
+ "url": "https://github.com/symfony/polyfill-intl-normalizer.git",
+ "reference": "a95281b0be0d9ab48050ebd988b967875cdb9fdb"
+ },
+ "dist": {
+ "type": "zip",
+ "url": "https://api.github.com/repos/symfony/polyfill-intl-normalizer/zipball/a95281b0be0d9ab48050ebd988b967875cdb9fdb",
+ "reference": "a95281b0be0d9ab48050ebd988b967875cdb9fdb",
+ "shasum": ""
+ },
+ "require": {
+ "php": ">=7.1"
+ },
+ "suggest": {
+ "ext-intl": "For best performance"
+ },
+ "type": "library",
+ "extra": {
+ "thanks": {
+ "name": "symfony/polyfill",
+ "url": "https://github.com/symfony/polyfill"
+ }
+ },
+ "autoload": {
+ "files": [
+ "bootstrap.php"
+ ],
+ "psr-4": {
+ "Symfony\\Polyfill\\Intl\\Normalizer\\": ""
+ },
+ "classmap": [
+ "Resources/stubs"
+ ]
+ },
+ "notification-url": "https://packagist.org/downloads/",
+ "license": [
+ "MIT"
+ ],
+ "authors": [
+ {
+ "name": "Nicolas Grekas",
+ "email": "p@tchwork.com"
+ },
+ {
+ "name": "Symfony Community",
+ "homepage": "https://symfony.com/contributors"
+ }
+ ],
+ "description": "Symfony polyfill for intl's Normalizer class and related functions",
+ "homepage": "https://symfony.com",
+ "keywords": [
+ "compatibility",
+ "intl",
+ "normalizer",
+ "polyfill",
+ "portable",
+ "shim"
+ ],
+ "support": {
+ "source": "https://github.com/symfony/polyfill-intl-normalizer/tree/v1.30.0"
+ },
+ "funding": [
+ {
+ "url": "https://symfony.com/sponsor",
+ "type": "custom"
+ },
+ {
+ "url": "https://github.com/fabpot",
+ "type": "github"
+ },
+ {
+ "url": "https://tidelift.com/funding/github/packagist/symfony/symfony",
+ "type": "tidelift"
+ }
+ ],
+ "time": "2024-05-31T15:07:36+00:00"
+ },
+ {
+ "name": "symfony/polyfill-mbstring",
+ "version": "v1.30.0",
+ "source": {
+ "type": "git",
+ "url": "https://github.com/symfony/polyfill-mbstring.git",
+ "reference": "fd22ab50000ef01661e2a31d850ebaa297f8e03c"
+ },
+ "dist": {
+ "type": "zip",
+ "url": "https://api.github.com/repos/symfony/polyfill-mbstring/zipball/fd22ab50000ef01661e2a31d850ebaa297f8e03c",
+ "reference": "fd22ab50000ef01661e2a31d850ebaa297f8e03c",
+ "shasum": ""
+ },
+ "require": {
+ "php": ">=7.1"
+ },
+ "provide": {
+ "ext-mbstring": "*"
+ },
+ "suggest": {
+ "ext-mbstring": "For best performance"
+ },
+ "type": "library",
+ "extra": {
+ "thanks": {
+ "name": "symfony/polyfill",
+ "url": "https://github.com/symfony/polyfill"
+ }
+ },
+ "autoload": {
+ "files": [
+ "bootstrap.php"
+ ],
+ "psr-4": {
+ "Symfony\\Polyfill\\Mbstring\\": ""
+ }
+ },
+ "notification-url": "https://packagist.org/downloads/",
+ "license": [
+ "MIT"
+ ],
+ "authors": [
+ {
+ "name": "Nicolas Grekas",
+ "email": "p@tchwork.com"
+ },
+ {
+ "name": "Symfony Community",
+ "homepage": "https://symfony.com/contributors"
+ }
+ ],
+ "description": "Symfony polyfill for the Mbstring extension",
+ "homepage": "https://symfony.com",
+ "keywords": [
+ "compatibility",
+ "mbstring",
+ "polyfill",
+ "portable",
+ "shim"
+ ],
+ "support": {
+ "source": "https://github.com/symfony/polyfill-mbstring/tree/v1.30.0"
+ },
+ "funding": [
+ {
+ "url": "https://symfony.com/sponsor",
+ "type": "custom"
+ },
+ {
+ "url": "https://github.com/fabpot",
+ "type": "github"
+ },
+ {
+ "url": "https://tidelift.com/funding/github/packagist/symfony/symfony",
+ "type": "tidelift"
+ }
+ ],
+ "time": "2024-06-19T12:30:46+00:00"
+ },
+ {
+ "name": "symfony/polyfill-php80",
+ "version": "v1.30.0",
"source": {
"type": "git",
- "url": "https://github.com/magento/magento-coding-standard.git",
- "reference": "097bda3e015f35dc7c2efc0b8c7a7d8dfc158a63"
+ "url": "https://github.com/symfony/polyfill-php80.git",
+ "reference": "77fa7995ac1b21ab60769b7323d600a991a90433"
},
"dist": {
"type": "zip",
- "url": "https://api.github.com/repos/magento/magento-coding-standard/zipball/097bda3e015f35dc7c2efc0b8c7a7d8dfc158a63",
- "reference": "097bda3e015f35dc7c2efc0b8c7a7d8dfc158a63",
+ "url": "https://api.github.com/repos/symfony/polyfill-php80/zipball/77fa7995ac1b21ab60769b7323d600a991a90433",
+ "reference": "77fa7995ac1b21ab60769b7323d600a991a90433",
"shasum": ""
},
"require": {
- "ext-dom": "*",
- "ext-simplexml": "*",
- "php": "^8.1||^8.2",
- "phpcompatibility/php-compatibility": "^9.3",
- "rector/rector": "^0.13.0",
- "squizlabs/php_codesniffer": "^3.6.1",
- "webonyx/graphql-php": "^14.9"
+ "php": ">=7.1"
},
- "require-dev": {
- "phpunit/phpunit": "^9.5.8"
+ "type": "library",
+ "extra": {
+ "thanks": {
+ "name": "symfony/polyfill",
+ "url": "https://github.com/symfony/polyfill"
+ }
},
- "type": "phpcodesniffer-standard",
"autoload": {
+ "files": [
+ "bootstrap.php"
+ ],
"psr-4": {
- "Magento2\\": "Magento2/",
- "Magento2Framework\\": "Magento2Framework/"
+ "Symfony\\Polyfill\\Php80\\": ""
},
"classmap": [
- "PHP_CodeSniffer/Tokenizers/"
+ "Resources/stubs"
]
},
"notification-url": "https://packagist.org/downloads/",
"license": [
- "OSL-3.0",
- "AFL-3.0"
+ "MIT"
+ ],
+ "authors": [
+ {
+ "name": "Ion Bazan",
+ "email": "ion.bazan@gmail.com"
+ },
+ {
+ "name": "Nicolas Grekas",
+ "email": "p@tchwork.com"
+ },
+ {
+ "name": "Symfony Community",
+ "homepage": "https://symfony.com/contributors"
+ }
+ ],
+ "description": "Symfony polyfill backporting some PHP 8.0+ features to lower PHP versions",
+ "homepage": "https://symfony.com",
+ "keywords": [
+ "compatibility",
+ "polyfill",
+ "portable",
+ "shim"
],
- "description": "A set of Magento specific PHP CodeSniffer rules.",
"support": {
- "issues": "https://github.com/magento/magento-coding-standard/issues",
- "source": "https://github.com/magento/magento-coding-standard/tree/v27"
+ "source": "https://github.com/symfony/polyfill-php80/tree/v1.30.0"
},
- "time": "2022-10-17T15:19:28+00:00"
+ "funding": [
+ {
+ "url": "https://symfony.com/sponsor",
+ "type": "custom"
+ },
+ {
+ "url": "https://github.com/fabpot",
+ "type": "github"
+ },
+ {
+ "url": "https://tidelift.com/funding/github/packagist/symfony/symfony",
+ "type": "tidelift"
+ }
+ ],
+ "time": "2024-05-31T15:07:36+00:00"
},
{
- "name": "phpcompatibility/php-compatibility",
- "version": "9.3.5",
+ "name": "symfony/polyfill-php81",
+ "version": "v1.30.0",
"source": {
"type": "git",
- "url": "https://github.com/PHPCompatibility/PHPCompatibility.git",
- "reference": "9fb324479acf6f39452e0655d2429cc0d3914243"
+ "url": "https://github.com/symfony/polyfill-php81.git",
+ "reference": "3fb075789fb91f9ad9af537c4012d523085bd5af"
},
"dist": {
"type": "zip",
- "url": "https://api.github.com/repos/PHPCompatibility/PHPCompatibility/zipball/9fb324479acf6f39452e0655d2429cc0d3914243",
- "reference": "9fb324479acf6f39452e0655d2429cc0d3914243",
+ "url": "https://api.github.com/repos/symfony/polyfill-php81/zipball/3fb075789fb91f9ad9af537c4012d523085bd5af",
+ "reference": "3fb075789fb91f9ad9af537c4012d523085bd5af",
"shasum": ""
},
"require": {
- "php": ">=5.3",
- "squizlabs/php_codesniffer": "^2.3 || ^3.0.2"
- },
- "conflict": {
- "squizlabs/php_codesniffer": "2.6.2"
+ "php": ">=7.1"
},
- "require-dev": {
- "phpunit/phpunit": "~4.5 || ^5.0 || ^6.0 || ^7.0"
+ "type": "library",
+ "extra": {
+ "thanks": {
+ "name": "symfony/polyfill",
+ "url": "https://github.com/symfony/polyfill"
+ }
},
- "suggest": {
- "dealerdirect/phpcodesniffer-composer-installer": "^0.5 || This Composer plugin will sort out the PHPCS 'installed_paths' automatically.",
- "roave/security-advisories": "dev-master || Helps prevent installing dependencies with known security issues."
+ "autoload": {
+ "files": [
+ "bootstrap.php"
+ ],
+ "psr-4": {
+ "Symfony\\Polyfill\\Php81\\": ""
+ },
+ "classmap": [
+ "Resources/stubs"
+ ]
},
- "type": "phpcodesniffer-standard",
"notification-url": "https://packagist.org/downloads/",
"license": [
- "LGPL-3.0-or-later"
+ "MIT"
],
"authors": [
{
- "name": "Wim Godden",
- "homepage": "https://github.com/wimg",
- "role": "lead"
- },
- {
- "name": "Juliette Reinders Folmer",
- "homepage": "https://github.com/jrfnl",
- "role": "lead"
+ "name": "Nicolas Grekas",
+ "email": "p@tchwork.com"
},
{
- "name": "Contributors",
- "homepage": "https://github.com/PHPCompatibility/PHPCompatibility/graphs/contributors"
+ "name": "Symfony Community",
+ "homepage": "https://symfony.com/contributors"
}
],
- "description": "A set of sniffs for PHP_CodeSniffer that checks for PHP cross-version compatibility.",
- "homepage": "http://techblog.wimgodden.be/tag/codesniffer/",
+ "description": "Symfony polyfill backporting some PHP 8.1+ features to lower PHP versions",
+ "homepage": "https://symfony.com",
"keywords": [
"compatibility",
- "phpcs",
- "standards"
+ "polyfill",
+ "portable",
+ "shim"
],
"support": {
- "issues": "https://github.com/PHPCompatibility/PHPCompatibility/issues",
- "source": "https://github.com/PHPCompatibility/PHPCompatibility"
+ "source": "https://github.com/symfony/polyfill-php81/tree/v1.30.0"
},
- "time": "2019-12-27T09:44:58+00:00"
+ "funding": [
+ {
+ "url": "https://symfony.com/sponsor",
+ "type": "custom"
+ },
+ {
+ "url": "https://github.com/fabpot",
+ "type": "github"
+ },
+ {
+ "url": "https://tidelift.com/funding/github/packagist/symfony/symfony",
+ "type": "tidelift"
+ }
+ ],
+ "time": "2024-06-19T12:30:46+00:00"
},
{
- "name": "phpstan/phpstan",
- "version": "1.9.2",
+ "name": "symfony/process",
+ "version": "v6.4.8",
"source": {
"type": "git",
- "url": "https://github.com/phpstan/phpstan.git",
- "reference": "d6fdf01c53978b6429f1393ba4afeca39cc68afa"
+ "url": "https://github.com/symfony/process.git",
+ "reference": "8d92dd79149f29e89ee0f480254db595f6a6a2c5"
},
"dist": {
"type": "zip",
- "url": "https://api.github.com/repos/phpstan/phpstan/zipball/d6fdf01c53978b6429f1393ba4afeca39cc68afa",
- "reference": "d6fdf01c53978b6429f1393ba4afeca39cc68afa",
+ "url": "https://api.github.com/repos/symfony/process/zipball/8d92dd79149f29e89ee0f480254db595f6a6a2c5",
+ "reference": "8d92dd79149f29e89ee0f480254db595f6a6a2c5",
"shasum": ""
},
"require": {
- "php": "^7.2|^8.0"
- },
- "conflict": {
- "phpstan/phpstan-shim": "*"
+ "php": ">=8.1"
},
- "bin": [
- "phpstan",
- "phpstan.phar"
- ],
"type": "library",
"autoload": {
- "files": [
- "bootstrap.php"
+ "psr-4": {
+ "Symfony\\Component\\Process\\": ""
+ },
+ "exclude-from-classmap": [
+ "/Tests/"
]
},
"notification-url": "https://packagist.org/downloads/",
"license": [
"MIT"
],
- "description": "PHPStan - PHP Static Analysis Tool",
- "keywords": [
- "dev",
- "static analysis"
+ "authors": [
+ {
+ "name": "Fabien Potencier",
+ "email": "fabien@symfony.com"
+ },
+ {
+ "name": "Symfony Community",
+ "homepage": "https://symfony.com/contributors"
+ }
],
+ "description": "Executes commands in sub-processes",
+ "homepage": "https://symfony.com",
"support": {
- "issues": "https://github.com/phpstan/phpstan/issues",
- "source": "https://github.com/phpstan/phpstan/tree/1.9.2"
+ "source": "https://github.com/symfony/process/tree/v6.4.8"
},
"funding": [
{
- "url": "https://github.com/ondrejmirtes",
- "type": "github"
+ "url": "https://symfony.com/sponsor",
+ "type": "custom"
},
{
- "url": "https://github.com/phpstan",
+ "url": "https://github.com/fabpot",
"type": "github"
},
{
- "url": "https://tidelift.com/funding/github/packagist/phpstan/phpstan",
+ "url": "https://tidelift.com/funding/github/packagist/symfony/symfony",
"type": "tidelift"
}
],
- "time": "2022-11-10T09:56:11+00:00"
+ "time": "2024-05-31T14:49:08+00:00"
},
{
- "name": "rector/rector",
- "version": "0.13.10",
+ "name": "symfony/service-contracts",
+ "version": "v3.5.0",
"source": {
"type": "git",
- "url": "https://github.com/rectorphp/rector.git",
- "reference": "d1e069db8ad3b4aea2b968248370c21415e4c180"
+ "url": "https://github.com/symfony/service-contracts.git",
+ "reference": "bd1d9e59a81d8fa4acdcea3f617c581f7475a80f"
},
"dist": {
"type": "zip",
- "url": "https://api.github.com/repos/rectorphp/rector/zipball/d1e069db8ad3b4aea2b968248370c21415e4c180",
- "reference": "d1e069db8ad3b4aea2b968248370c21415e4c180",
+ "url": "https://api.github.com/repos/symfony/service-contracts/zipball/bd1d9e59a81d8fa4acdcea3f617c581f7475a80f",
+ "reference": "bd1d9e59a81d8fa4acdcea3f617c581f7475a80f",
"shasum": ""
},
"require": {
- "php": "^7.2|^8.0",
- "phpstan/phpstan": "^1.8.2"
+ "php": ">=8.1",
+ "psr/container": "^1.1|^2.0",
+ "symfony/deprecation-contracts": "^2.5|^3"
},
"conflict": {
- "phpstan/phpdoc-parser": "<1.6.2",
- "rector/rector-cakephp": "*",
- "rector/rector-doctrine": "*",
- "rector/rector-laravel": "*",
- "rector/rector-nette": "*",
- "rector/rector-phpoffice": "*",
- "rector/rector-phpunit": "*",
- "rector/rector-prefixed": "*",
- "rector/rector-symfony": "*"
+ "ext-psr": "<1.1|>=2"
},
- "bin": [
- "bin/rector"
- ],
"type": "library",
"extra": {
"branch-alias": {
- "dev-main": "0.13-dev"
+ "dev-main": "3.5-dev"
+ },
+ "thanks": {
+ "name": "symfony/contracts",
+ "url": "https://github.com/symfony/contracts"
}
},
"autoload": {
- "files": [
- "bootstrap.php"
+ "psr-4": {
+ "Symfony\\Contracts\\Service\\": ""
+ },
+ "exclude-from-classmap": [
+ "/Test/"
]
},
"notification-url": "https://packagist.org/downloads/",
"license": [
"MIT"
],
- "description": "Instant Upgrade and Automated Refactoring of any PHP code",
+ "authors": [
+ {
+ "name": "Nicolas Grekas",
+ "email": "p@tchwork.com"
+ },
+ {
+ "name": "Symfony Community",
+ "homepage": "https://symfony.com/contributors"
+ }
+ ],
+ "description": "Generic abstractions related to writing services",
+ "homepage": "https://symfony.com",
+ "keywords": [
+ "abstractions",
+ "contracts",
+ "decoupling",
+ "interfaces",
+ "interoperability",
+ "standards"
+ ],
"support": {
- "issues": "https://github.com/rectorphp/rector/issues",
- "source": "https://github.com/rectorphp/rector/tree/0.13.10"
+ "source": "https://github.com/symfony/service-contracts/tree/v3.5.0"
},
"funding": [
{
- "url": "https://github.com/tomasvotruba",
+ "url": "https://symfony.com/sponsor",
+ "type": "custom"
+ },
+ {
+ "url": "https://github.com/fabpot",
"type": "github"
+ },
+ {
+ "url": "https://tidelift.com/funding/github/packagist/symfony/symfony",
+ "type": "tidelift"
}
],
- "time": "2022-08-03T12:48:10+00:00"
+ "time": "2024-04-18T09:32:20+00:00"
},
{
- "name": "squizlabs/php_codesniffer",
- "version": "3.7.1",
+ "name": "symfony/stopwatch",
+ "version": "v6.4.8",
"source": {
"type": "git",
- "url": "https://github.com/squizlabs/PHP_CodeSniffer.git",
- "reference": "1359e176e9307e906dc3d890bcc9603ff6d90619"
+ "url": "https://github.com/symfony/stopwatch.git",
+ "reference": "63e069eb616049632cde9674c46957819454b8aa"
},
"dist": {
"type": "zip",
- "url": "https://api.github.com/repos/squizlabs/PHP_CodeSniffer/zipball/1359e176e9307e906dc3d890bcc9603ff6d90619",
- "reference": "1359e176e9307e906dc3d890bcc9603ff6d90619",
+ "url": "https://api.github.com/repos/symfony/stopwatch/zipball/63e069eb616049632cde9674c46957819454b8aa",
+ "reference": "63e069eb616049632cde9674c46957819454b8aa",
"shasum": ""
},
"require": {
- "ext-simplexml": "*",
- "ext-tokenizer": "*",
- "ext-xmlwriter": "*",
- "php": ">=5.4.0"
+ "php": ">=8.1",
+ "symfony/service-contracts": "^2.5|^3"
},
- "require-dev": {
- "phpunit/phpunit": "^4.0 || ^5.0 || ^6.0 || ^7.0"
+ "type": "library",
+ "autoload": {
+ "psr-4": {
+ "Symfony\\Component\\Stopwatch\\": ""
+ },
+ "exclude-from-classmap": [
+ "/Tests/"
+ ]
},
- "bin": [
- "bin/phpcs",
- "bin/phpcbf"
+ "notification-url": "https://packagist.org/downloads/",
+ "license": [
+ "MIT"
],
- "type": "library",
- "extra": {
- "branch-alias": {
- "dev-master": "3.x-dev"
+ "authors": [
+ {
+ "name": "Fabien Potencier",
+ "email": "fabien@symfony.com"
+ },
+ {
+ "name": "Symfony Community",
+ "homepage": "https://symfony.com/contributors"
+ }
+ ],
+ "description": "Provides a way to profile code",
+ "homepage": "https://symfony.com",
+ "support": {
+ "source": "https://github.com/symfony/stopwatch/tree/v6.4.8"
+ },
+ "funding": [
+ {
+ "url": "https://symfony.com/sponsor",
+ "type": "custom"
+ },
+ {
+ "url": "https://github.com/fabpot",
+ "type": "github"
+ },
+ {
+ "url": "https://tidelift.com/funding/github/packagist/symfony/symfony",
+ "type": "tidelift"
}
+ ],
+ "time": "2024-05-31T14:49:08+00:00"
+ },
+ {
+ "name": "symfony/string",
+ "version": "v6.4.10",
+ "source": {
+ "type": "git",
+ "url": "https://github.com/symfony/string.git",
+ "reference": "ccf9b30251719567bfd46494138327522b9a9446"
+ },
+ "dist": {
+ "type": "zip",
+ "url": "https://api.github.com/repos/symfony/string/zipball/ccf9b30251719567bfd46494138327522b9a9446",
+ "reference": "ccf9b30251719567bfd46494138327522b9a9446",
+ "shasum": ""
+ },
+ "require": {
+ "php": ">=8.1",
+ "symfony/polyfill-ctype": "~1.8",
+ "symfony/polyfill-intl-grapheme": "~1.0",
+ "symfony/polyfill-intl-normalizer": "~1.0",
+ "symfony/polyfill-mbstring": "~1.0"
+ },
+ "conflict": {
+ "symfony/translation-contracts": "<2.5"
+ },
+ "require-dev": {
+ "symfony/error-handler": "^5.4|^6.0|^7.0",
+ "symfony/http-client": "^5.4|^6.0|^7.0",
+ "symfony/intl": "^6.2|^7.0",
+ "symfony/translation-contracts": "^2.5|^3.0",
+ "symfony/var-exporter": "^5.4|^6.0|^7.0"
+ },
+ "type": "library",
+ "autoload": {
+ "files": [
+ "Resources/functions.php"
+ ],
+ "psr-4": {
+ "Symfony\\Component\\String\\": ""
+ },
+ "exclude-from-classmap": [
+ "/Tests/"
+ ]
},
"notification-url": "https://packagist.org/downloads/",
"license": [
- "BSD-3-Clause"
+ "MIT"
],
"authors": [
{
- "name": "Greg Sherwood",
- "role": "lead"
+ "name": "Nicolas Grekas",
+ "email": "p@tchwork.com"
+ },
+ {
+ "name": "Symfony Community",
+ "homepage": "https://symfony.com/contributors"
}
],
- "description": "PHP_CodeSniffer tokenizes PHP, JavaScript and CSS files and detects violations of a defined set of coding standards.",
- "homepage": "https://github.com/squizlabs/PHP_CodeSniffer",
+ "description": "Provides an object-oriented API to strings and deals with bytes, UTF-8 code points and grapheme clusters in a unified way",
+ "homepage": "https://symfony.com",
"keywords": [
- "phpcs",
- "standards"
+ "grapheme",
+ "i18n",
+ "string",
+ "unicode",
+ "utf-8",
+ "utf8"
],
"support": {
- "issues": "https://github.com/squizlabs/PHP_CodeSniffer/issues",
- "source": "https://github.com/squizlabs/PHP_CodeSniffer",
- "wiki": "https://github.com/squizlabs/PHP_CodeSniffer/wiki"
+ "source": "https://github.com/symfony/string/tree/v6.4.10"
},
- "time": "2022-06-18T07:21:10+00:00"
+ "funding": [
+ {
+ "url": "https://symfony.com/sponsor",
+ "type": "custom"
+ },
+ {
+ "url": "https://github.com/fabpot",
+ "type": "github"
+ },
+ {
+ "url": "https://tidelift.com/funding/github/packagist/symfony/symfony",
+ "type": "tidelift"
+ }
+ ],
+ "time": "2024-07-22T10:21:14+00:00"
},
{
"name": "webonyx/graphql-php",
- "version": "v14.11.8",
+ "version": "v15.12.5",
"source": {
"type": "git",
"url": "https://github.com/webonyx/graphql-php.git",
- "reference": "04a48693acd785330eefd3b0e4fa67df8dfee7c3"
+ "reference": "7bcd31d1dcf67781ed5cb493b22c519c539c05e6"
},
"dist": {
"type": "zip",
- "url": "https://api.github.com/repos/webonyx/graphql-php/zipball/04a48693acd785330eefd3b0e4fa67df8dfee7c3",
- "reference": "04a48693acd785330eefd3b0e4fa67df8dfee7c3",
+ "url": "https://api.github.com/repos/webonyx/graphql-php/zipball/7bcd31d1dcf67781ed5cb493b22c519c539c05e6",
+ "reference": "7bcd31d1dcf67781ed5cb493b22c519c539c05e6",
"shasum": ""
},
"require": {
"ext-json": "*",
"ext-mbstring": "*",
- "php": "^7.1 || ^8"
+ "php": "^7.4 || ^8"
},
"require-dev": {
- "amphp/amp": "^2.3",
- "doctrine/coding-standard": "^6.0",
- "nyholm/psr7": "^1.2",
+ "amphp/amp": "^2.6",
+ "amphp/http-server": "^2.1",
+ "dms/phpunit-arraysubset-asserts": "dev-master",
+ "ergebnis/composer-normalize": "^2.28",
+ "friendsofphp/php-cs-fixer": "3.59.3",
+ "mll-lab/php-cs-fixer-config": "^5",
+ "nyholm/psr7": "^1.5",
"phpbench/phpbench": "^1.2",
- "phpstan/extension-installer": "^1.0",
- "phpstan/phpstan": "0.12.82",
- "phpstan/phpstan-phpunit": "0.12.18",
- "phpstan/phpstan-strict-rules": "0.12.9",
- "phpunit/phpunit": "^7.2 || ^8.5",
- "psr/http-message": "^1.0",
- "react/promise": "2.*",
- "simpod/php-coveralls-mirror": "^3.0",
- "squizlabs/php_codesniffer": "3.5.4"
+ "phpstan/extension-installer": "^1.1",
+ "phpstan/phpstan": "1.11.5",
+ "phpstan/phpstan-phpunit": "1.4.0",
+ "phpstan/phpstan-strict-rules": "1.6.0",
+ "phpunit/phpunit": "^9.5 || ^10.5.21",
+ "psr/http-message": "^1 || ^2",
+ "react/http": "^1.6",
+ "react/promise": "^2.0 || ^3.0",
+ "rector/rector": "^1.0",
+ "symfony/polyfill-php81": "^1.23",
+ "symfony/var-exporter": "^5 || ^6 || ^7",
+ "thecodingmachine/safe": "^1.3 || ^2"
},
"suggest": {
+ "amphp/http-server": "To leverage async resolving with webserver on AMPHP platform",
"psr/http-message": "To use standard GraphQL server",
"react/promise": "To leverage async resolving on React PHP platform"
},
@@ -347,7 +3081,7 @@
],
"support": {
"issues": "https://github.com/webonyx/graphql-php/issues",
- "source": "https://github.com/webonyx/graphql-php/tree/v14.11.8"
+ "source": "https://github.com/webonyx/graphql-php/tree/v15.12.5"
},
"funding": [
{
@@ -355,16 +3089,17 @@
"type": "open_collective"
}
],
- "time": "2022-09-21T15:35:03+00:00"
+ "time": "2024-06-23T11:30:58+00:00"
}
],
- "packages-dev": [],
"aliases": [],
"minimum-stability": "stable",
"stability-flags": [],
"prefer-stable": false,
"prefer-lowest": false,
"platform": [],
- "platform-dev": [],
- "plugin-api-version": "2.3.0"
+ "platform-dev": {
+ "composer": "*"
+ },
+ "plugin-api-version": "2.6.0"
}
diff --git a/view/adminhtml/templates/facettitles.phtml b/view/adminhtml/templates/facettitles.phtml
index 4e75c7f..e12b780 100644
--- a/view/adminhtml/templates/facettitles.phtml
+++ b/view/adminhtml/templates/facettitles.phtml
@@ -1,5 +1,8 @@
getElement();
$values = [];
$values = (null === $element->getValue()) ? [] : json_decode($element->getValue(), true);
@@ -14,20 +17,25 @@ $values = (null === $element->getValue()) ? [] : json_decode($element->getValue(
- getConfiguredAttributes() as $attribute): ?>
-
+ getConfiguredAttributes() as $attribute): ?>
+
|
+
|
-
+
|
-
+
|
-
+
\ No newline at end of file
diff --git a/view/adminhtml/web/js/admin_clerk.js b/view/adminhtml/web/js/admin_clerk.js
index 15b9aaa..3837be7 100644
--- a/view/adminhtml/web/js/admin_clerk.js
+++ b/view/adminhtml/web/js/admin_clerk.js
@@ -9,13 +9,13 @@ require(
$('#clerk_log_level').focus(function () {
- before_logging_level = $('#clerk_log_level').val();
+ let before_logging_level = $('#clerk_log_level').val();
}).change(function () {
- log_level = $(this).val();
+ let log_level = $(this).val();
- if (log_level == 'all') {
+ if (log_level === 'all') {
confirmation({
title: $.mage.__('Changing Logging Level'),
@@ -44,8 +44,7 @@ require(
}]
});
- }
- else {
+ } else {
before_logging_level = $('#clerk_log_level').val();
diff --git a/view/frontend/templates/added.phtml b/view/frontend/templates/added.phtml
index c4d68e8..0ddeccb 100644
--- a/view/frontend/templates/added.phtml
+++ b/view/frontend/templates/added.phtml
@@ -1,10 +1,14 @@
-
; ?>)
- escapeHtml($block->getProduct()->getName())); ?>
+
; ?>)
+ escapeHtml($block->getProduct()->getName())); ?>
-getExcludeState();
$slider_count = 0;
$spanAttributes = [];
@@ -28,34 +32,33 @@
$spanAttributes['products'] = $block->getProduct()->getId();
$spanAttributes['category'] = $block->getProduct()->getCategoryId();
-foreach ($block->getTemplates() as $template):
- if ($filter_duplicates) {
- $spanAttributes['class'] = 'clerk clerk_' . (string)$slider_count;
- }
- if ($slider_count > 0 && $filter_duplicates) {
- $filter_string = '';
- for ($i = 0; $i < $slider_count; $i++) {
- if ($i > 0) {
- $filter_string .= ', ';
+ foreach ($block->getTemplates() as $template):
+ if ($filter_duplicates) {
+ $spanAttributes['class'] = 'clerk clerk_' . (string)$slider_count;
+ }
+ if ($slider_count > 0 && $filter_duplicates) {
+ $filter_string = '';
+ for ($i = 0; $i < $slider_count; $i++) {
+ if ($i > 0) {
+ $filter_string .= ', ';
+ }
+ $filter_string .= '.clerk_' . (string)$i;
}
- $filter_string .= '.clerk_'.(string)$i;
+ $spanAttributes['exclude'] = $filter_string;
}
- $spanAttributes['exclude'] = $filter_string;
- }
- ?>
-
+ 0 && $filter_duplicates) {
- echo 'data-exclude-from="'.$spanAttributes['exclude'].'"';
+ echo 'data-exclude-from="' . $spanAttributes['exclude'] . '"';
}
?>
data-template="@"
- data-products="[]"
- data-category=""
- >
- ]"
+ data-category=""
+ >
+
+ ?>
\ No newline at end of file
diff --git a/view/frontend/templates/powerstep_script.phtml b/view/frontend/templates/powerstep_script.phtml
index 7e54629..7b76f7a 100644
--- a/view/frontend/templates/powerstep_script.phtml
+++ b/view/frontend/templates/powerstep_script.phtml
@@ -1,49 +1,41 @@
shouldShow()):
?>
-
+ $(document).ready(function () {
+ let product_added_with_reload = (document.querySelectorAll('[data-ui-id="message-success"]').length > 0);
+ if (product_added_with_reload) {
+ getPowerstepPopup();
+ }
+ });
+ });
+
\ No newline at end of file
diff --git a/view/frontend/templates/tracking.phtml b/view/frontend/templates/tracking.phtml
index 102d181..d5df559 100644
--- a/view/frontend/templates/tracking.phtml
+++ b/view/frontend/templates/tracking.phtml
@@ -9,7 +9,7 @@ if (!empty($block->getPublicKey())):
var e = d.createElement('script');
e.type = 'text/javascript';
e.async = true;
- e.src = (d.location.protocol == 'https:' ? 'https' : 'http') + '';
+ e.src = (d.location.protocol === 'https:' ? 'https' : 'http') + '';
var s = d.getElementsByTagName('script')[0];
s.parentNode.insertBefore(e, s);
w.__clerk_q = w.__clerk_q || [];
@@ -65,7 +65,7 @@ if (!empty($block->getPublicKey())):
- var collectbaskets = getCollectionBaskets(); ?>;
+ let collectbaskets = 'getCollectionBaskets(); ?>' === 'true';
if (collectbaskets) {
@@ -76,33 +76,32 @@ if (!empty($block->getPublicKey())):
if (this.responseURL.includes("=cart")) {
if (this.readyState === 4 && this.status === 200) {
- var response = JSON.parse(this.responseText);
+ const response = JSON.parse(this.responseText);
- var clerk_productids = [];
+ let clerk_productids = [];
if (response && response.hasOwnProperty('cart') && response.cart.hasOwnProperty('items')) {
- for (var i = 0, len = response.cart.items.length; i < len; i++) {
+ let i = 0, len = response.cart.items.length;
+ for (; i < len; i++) {
clerk_productids.push(response.cart.items[i].product_id);
}
}
clerk_productids = clerk_productids.map(Number);
- var clerk_last_productids = [];
+ let clerk_last_productids = [];
if (localStorage.getItem('clerk_productids') !== null) {
clerk_last_productids = localStorage.getItem('clerk_productids').split(",");
clerk_last_productids = clerk_last_productids.map(Number);
}
clerk_productids = clerk_productids.sort((a, b) => a - b);
clerk_last_productids = clerk_last_productids.sort((a, b) => a - b);
- if (JSON.stringify(clerk_productids) == JSON.stringify(clerk_last_productids)) {
- // if equal - do nothing
- } else {
+ if (JSON.stringify(clerk_productids) !== JSON.stringify(clerk_last_productids)) {
if (JSON.stringify(clerk_productids) === "[0]") {
Clerk('cart', 'set', []);
} else {
Clerk('cart', 'set', clerk_productids);
}
}
- localStorage.setItem("clerk_productids", clerk_productids);
+ localStorage.setItem("clerk_productids", JSON.stringify(clerk_productids));
}
}
}, false);