-
Notifications
You must be signed in to change notification settings - Fork 5
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
194 changed files
with
62,190 additions
and
47 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
<?php | ||
|
||
namespace Synerise\Integration\Block\Adminhtml\SearchIndex\Assign; | ||
|
||
use Magento\Framework\View\Element\UiComponent\Control\ButtonProviderInterface; | ||
use Synerise\Integration\Block\Adminhtml\SearchIndex\GenericButton; | ||
|
||
class SaveButton extends GenericButton implements ButtonProviderInterface | ||
{ | ||
/** | ||
* Get button data | ||
* | ||
* @return array | ||
*/ | ||
public function getButtonData() | ||
{ | ||
return [ | ||
'label' => __('Save'), | ||
'class' => 'save primary', | ||
'data_attribute' => [ | ||
'mage-init' => [ | ||
'buttonAdapter' => [ | ||
'actions' => [ | ||
[ | ||
'targetName' => 'synerise_searchindex_assign_form.synerise_searchindex_assign_form', | ||
'actionName' => 'save', | ||
'params' => [ | ||
true, | ||
['store_id' => $this->context->getRequest()->getParam('store')] | ||
] | ||
], | ||
], | ||
], | ||
], | ||
] | ||
]; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
<?php | ||
|
||
namespace Synerise\Integration\Block\Adminhtml\SearchIndex; | ||
|
||
use Magento\Framework\View\Element\UiComponent\Control\ButtonProviderInterface; | ||
|
||
class BackButton extends GenericButton implements ButtonProviderInterface | ||
{ | ||
/** | ||
* Get button data | ||
* | ||
* @return array | ||
*/ | ||
public function getButtonData() | ||
{ | ||
return [ | ||
'label' => __('Back'), | ||
'on_click' => sprintf("location.href = '%s';", $this->getBackUrl()), | ||
'class' => 'back', | ||
'sort_order' => 10, | ||
]; | ||
} | ||
|
||
/** | ||
* Get URL for back (reset) button | ||
* | ||
* @return string | ||
*/ | ||
public function getBackUrl() | ||
{ | ||
return $this->getUrl('*/*/'); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
<?php | ||
|
||
namespace Synerise\Integration\Block\Adminhtml\SearchIndex; | ||
|
||
use Magento\Backend\Block\Widget\Context; | ||
|
||
class GenericButton | ||
{ | ||
/** | ||
* @var Context | ||
*/ | ||
protected $context; | ||
|
||
/** | ||
* @param Context $context | ||
*/ | ||
public function __construct( | ||
Context $context | ||
) { | ||
$this->context = $context; | ||
} | ||
|
||
/** | ||
* Generate url by route and parameters | ||
* | ||
* @param string $route | ||
* @param array $params | ||
* @return string | ||
*/ | ||
public function getUrl($route = '', $params = []): string | ||
{ | ||
return $this->context->getUrlBuilder()->getUrl($route, $params); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
<?php | ||
|
||
namespace Synerise\Integration\Block\Adminhtml\SearchIndex\Setup; | ||
|
||
use Magento\Framework\View\Element\UiComponent\Control\ButtonProviderInterface; | ||
use Synerise\Integration\Block\Adminhtml\SearchIndex\GenericButton; | ||
|
||
class SaveButton extends GenericButton implements ButtonProviderInterface | ||
{ | ||
/** | ||
* Get button data | ||
* | ||
* @return array | ||
*/ | ||
public function getButtonData() | ||
{ | ||
return [ | ||
'label' => __('Save'), | ||
'class' => 'save primary', | ||
'data_attribute' => [ | ||
'mage-init' => [ | ||
'buttonAdapter' => [ | ||
'actions' => [ | ||
[ | ||
'targetName' => 'synerise_searchindex_setup_form.synerise_searchindex_setup_form', | ||
'actionName' => 'save', | ||
'params' => [false] | ||
], | ||
], | ||
], | ||
], | ||
] | ||
]; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
<?php | ||
|
||
namespace Synerise\Integration\Block\Adminhtml\SearchIndex\Store; | ||
|
||
use Magento\Framework\View\Element\UiComponent\Control\ButtonProviderInterface; | ||
use Synerise\Integration\Block\Adminhtml\SearchIndex\GenericButton; | ||
|
||
class ApplyButton extends GenericButton implements ButtonProviderInterface | ||
{ | ||
/** | ||
* Get button data | ||
* | ||
* @return array | ||
*/ | ||
public function getButtonData() | ||
{ | ||
return [ | ||
'label' => __('Apply'), | ||
'class' => 'save primary', | ||
'data_attribute' => [ | ||
'mage-init' => [ | ||
'buttonAdapter' => [ | ||
'actions' => [ | ||
[ | ||
'targetName' => 'synerise_searchindex_store_form.synerise_searchindex_store_form', | ||
'actionName' => 'save', | ||
'params' => [true] | ||
], | ||
], | ||
], | ||
], | ||
] | ||
]; | ||
} | ||
} |
55 changes: 55 additions & 0 deletions
55
Block/ElasticsuiteSwatches/Navigation/Renderer/Swatches/RenderLayered.php
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,55 @@ | ||
<?php | ||
|
||
namespace Synerise\Integration\Block\ElasticsuiteSwatches\Navigation\Renderer\Swatches; | ||
|
||
use Magento\Catalog\Model\Layer\Resolver; | ||
use Magento\Catalog\Model\ResourceModel\Layer\Filter\AttributeFactory; | ||
use Magento\Eav\Model\Entity\Attribute; | ||
use Magento\Eav\Model\Entity\Attribute\Option; | ||
use Magento\Framework\View\Element\Template; | ||
use Magento\Framework\View\Element\Template\Context; | ||
use Magento\Swatches\Helper\Data; | ||
use Magento\Swatches\Helper\Media; | ||
use Magento\Theme\Block\Html\Pager; | ||
|
||
if (!class_exists('Smile\ElasticsuiteSwatches\Block\Navigation\Renderer\Swatches\RenderLayered')) { | ||
class RenderLayered extends Template {} | ||
} else { | ||
class RenderLayered extends \Smile\ElasticsuiteSwatches\Block\Navigation\Renderer\Swatches\RenderLayered | ||
{ | ||
public const COLLECTION_CLASS = 'Smile\ElasticsuiteCatalog\Model\ResourceModel\Product\Fulltext\Collection'; | ||
|
||
public function __construct( | ||
Context $context, | ||
Attribute $eavAttribute, | ||
AttributeFactory $layerAttribute, | ||
Data $swatchHelper, | ||
Media $mediaHelper, | ||
Resolver $layerResolver, | ||
array $data = [], | ||
?Pager $htmlPagerBlock = null | ||
) { | ||
$layer = $layerResolver->get(); | ||
$this->canExecute = $layer && is_a($layer->getProductCollection(), self::COLLECTION_CLASS); | ||
|
||
parent::__construct($context, $eavAttribute, $layerAttribute, $swatchHelper, $mediaHelper, $data, $htmlPagerBlock); | ||
} | ||
|
||
/** | ||
* {@inheritDoc} | ||
*/ | ||
protected function getFilterOption(array $filterItems, Option $swatchOption) | ||
{ | ||
if ($this->canExecute) { | ||
return parent::getFilterOption($filterItems, $swatchOption); | ||
} | ||
|
||
$filterItem = $this->getFilterItemById($filterItems, $swatchOption->getValue()); | ||
if ($filterItem && $this->isOptionVisible($filterItem)) { | ||
return $this->getOptionViewData($filterItem, $swatchOption); | ||
} | ||
|
||
return false; | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,51 @@ | ||
<?php | ||
|
||
namespace Synerise\Integration\Block\ElasticsuiteTracker\Variables\Page; | ||
|
||
use Magento\Framework\View\Element\Template; | ||
|
||
if (!class_exists('Smile\ElasticsuiteTracker\Block\Variables\Page\Search')) { | ||
class Search extends Template | ||
{ } | ||
} else { | ||
class Search extends \Smile\ElasticsuiteTracker\Block\Variables\Page\Search | ||
{ | ||
public const COLLECTION_CLASS = 'Smile\ElasticsuiteCatalog\Model\ResourceModel\Product\Fulltext\Collection'; | ||
|
||
public function __construct( | ||
Template\Context $context, | ||
\Magento\Framework\Json\Helper\Data $jsonHelper, | ||
\Smile\ElasticsuiteTracker\Helper\Data $trackerHelper, | ||
\Magento\Framework\Registry $registry, | ||
\Magento\Catalog\Model\Layer\Resolver $layerResolver, | ||
\Magento\CatalogSearch\Helper\Data $catalogSearchData, | ||
\Smile\ElasticsuiteCore\Api\Search\ContextInterface $searchContext, | ||
array $data = [] | ||
) { | ||
$layer = $layerResolver->get(); | ||
$this->canExecute = $layer && is_a($layer->getProductCollection(), self::COLLECTION_CLASS); | ||
|
||
parent::__construct( | ||
$context, | ||
$jsonHelper, | ||
$trackerHelper, | ||
$registry, | ||
$layerResolver, | ||
$catalogSearchData, | ||
$searchContext, | ||
$data | ||
); | ||
} | ||
|
||
/** | ||
* @inheritDoc | ||
*/ | ||
public function getVariables() | ||
{ | ||
if ($this->canExecute) { | ||
return parent::getVariables(); | ||
} | ||
return []; | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,99 @@ | ||
<?php | ||
|
||
namespace Synerise\Integration\Controller\Adminhtml\SearchIndex; | ||
|
||
use Magento\Backend\App\Action; | ||
use Magento\Backend\App\Action\Context; | ||
use Magento\Framework\Controller\ResultFactory; | ||
use Magento\Framework\View\Result\PageFactory; | ||
use Synerise\Integration\Helper\Logger; | ||
use Synerise\Integration\Model\SearchIndex\ErrorMessage; | ||
use Synerise\Integration\Search\Container\Indices; | ||
use Synerise\ItemsSearchConfigApiClient\ApiException; | ||
|
||
class Assign extends Action | ||
{ | ||
/** | ||
* Authorization level | ||
*/ | ||
public const ADMIN_RESOURCE = 'Synerise_Integration::search_index_setup'; | ||
|
||
/** | ||
* @var PageFactory | ||
*/ | ||
protected $resultPageFactory; | ||
|
||
/** | ||
* @var ErrorMessage | ||
*/ | ||
protected $errorMessage; | ||
|
||
/** | ||
* @var Indices | ||
*/ | ||
protected $indices; | ||
|
||
/** | ||
* @var Logger | ||
*/ | ||
protected $logger; | ||
|
||
/** | ||
* @param Context $context | ||
* @param PageFactory $resultPageFactory | ||
* @param ErrorMessage $errorMessage | ||
* @param Indices $indices | ||
* @param Logger $logger | ||
*/ | ||
public function __construct( | ||
Action\Context $context, | ||
PageFactory $resultPageFactory, | ||
ErrorMessage $errorMessage, | ||
Indices $indices, | ||
Logger $logger | ||
) { | ||
$this->resultPageFactory = $resultPageFactory; | ||
$this->errorMessage = $errorMessage; | ||
$this->indices = $indices; | ||
$this->logger = $logger; | ||
|
||
parent::__construct($context); | ||
} | ||
|
||
/** | ||
* Edit Search Index | ||
* | ||
* @return \Magento\Framework\Controller\ResultInterface | ||
* @SuppressWarnings(PHPMD.NPathComplexity) | ||
*/ | ||
public function execute() | ||
{ | ||
if ($storeId = $this->getRequest()->getParam('store')) { | ||
try { | ||
$this->indices->getIndices($storeId); | ||
|
||
$resultPage = $this->resultFactory->create(ResultFactory::TYPE_PAGE); | ||
$resultPage->getConfig()->getTitle()->prepend(__('Assign Search Index (Store: %1)', $storeId)); | ||
return $resultPage; | ||
} catch (ApiException $exception) { | ||
$config = $this->errorMessage->getMessageFromConfigApiException($exception); | ||
if (isset($config['url'])) { | ||
$this->messageManager->addComplexErrorMessage( | ||
'messageWithUrl', | ||
[ | ||
'message' => $config['base_message'] . ' ' . $config['url_message'], | ||
'url' => $config['url'], | ||
] | ||
); | ||
} else { | ||
$this->messageManager->addErrorMessage($this->errorMessage->getDefaultMessage()); | ||
} | ||
} catch (\Exception $exception) { | ||
$this->logger->error($exception); | ||
$this->messageManager->addErrorMessage($this->errorMessage->getDefaultMessage()); | ||
} | ||
} | ||
|
||
return $this->resultRedirectFactory->create()->setPath('*/*'); | ||
} | ||
} |
Oops, something went wrong.