-
Notifications
You must be signed in to change notification settings - Fork 13
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
This is a sub package to the klevu-smart-search-M2 repository.
It is to enable indexing of products with Klevu Search. This is a mandatory package. Please, see klevu-smart-search-M2/README.md for more information on how to install the overall extension.
- Loading branch information
1 parent
4bcabfe
commit f54c20f
Showing
62 changed files
with
5,493 additions
and
300 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
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,140 @@ | ||
<?php | ||
|
||
namespace Klevu\Search\Block\Html\Head\ThemeV2; | ||
|
||
use Klevu\Search\Helper\Data as DataHelper; | ||
use Klevu\Search\Helper\VersionReader; | ||
use Klevu\Search\Service\ThemeV2\IsEnabledCondition; | ||
use Magento\Framework\App\Filesystem\DirectoryList; | ||
use Magento\Framework\Exception\NoSuchEntityException; | ||
use Magento\Framework\View\Element\Template; | ||
use Magento\Framework\View\Element\Template\Context; | ||
use Magento\Store\Api\Data\StoreInterface; | ||
|
||
class JsVariables extends Template | ||
{ | ||
/** | ||
* @var IsEnabledCondition | ||
*/ | ||
private $isEnabledCondition; | ||
|
||
/** | ||
* @var DataHelper | ||
*/ | ||
private $dataHelper; | ||
|
||
/** | ||
* @var DirectoryList | ||
*/ | ||
private $directoryList; | ||
|
||
/** | ||
* @var VersionReader | ||
*/ | ||
private $versionReader; | ||
|
||
/** | ||
* @var StoreInterface | ||
*/ | ||
private $currentStore; | ||
|
||
/** | ||
* @param Context $context | ||
* @param IsEnabledCondition $isEnabledCondition | ||
* @param DataHelper $dataHelper | ||
* @param DirectoryList $directoryList | ||
* @param VersionReader $versionReader | ||
* @param array $data | ||
*/ | ||
public function __construct( | ||
Context $context, | ||
IsEnabledCondition $isEnabledCondition, | ||
DataHelper $dataHelper, | ||
DirectoryList $directoryList, | ||
VersionReader $versionReader, | ||
array $data = [] | ||
) { | ||
parent::__construct($context, $data); | ||
|
||
$this->isEnabledCondition = $isEnabledCondition; | ||
$this->dataHelper = $dataHelper; | ||
$this->directoryList = $directoryList; | ||
$this->versionReader = $versionReader; | ||
} | ||
|
||
/** | ||
* @return string | ||
*/ | ||
public function getStoreLanguage() | ||
{ | ||
return $this->dataHelper->getStoreLanguage($this->getCurrentStore()); | ||
} | ||
|
||
/** | ||
* @return string|null | ||
*/ | ||
public function getCurrentCurrencyCode() | ||
{ | ||
$return = null; | ||
$store = $this->getCurrentStore(); | ||
if (method_exists($store, 'getCurrentCurrencyCode')) { | ||
$return = $store->getCurrentCurrencyCode(); | ||
} | ||
|
||
return $return; | ||
} | ||
|
||
/** | ||
* @return string | ||
*/ | ||
public function getCurrentCurrencyRates() | ||
{ | ||
return $this->dataHelper->getCurrencyData($this->getCurrentStore()); | ||
} | ||
|
||
/** | ||
* @return bool | ||
*/ | ||
public function isPubInUse() | ||
{ | ||
return 'pub' === $this->directoryList->getUrlPath(DirectoryList::PUB); | ||
} | ||
|
||
/** | ||
* @param string $moduleName | ||
* @return string | ||
*/ | ||
public function getModuleVersion($moduleName) | ||
{ | ||
return (string)$this->versionReader->getVersionString($moduleName); | ||
} | ||
|
||
/** | ||
* @return string | ||
*/ | ||
protected function _toHtml() | ||
{ | ||
$store = $this->getCurrentStore(); | ||
if (!$store || !$this->isEnabledCondition->execute((int)$store->getId())) { | ||
return ''; | ||
} | ||
|
||
return parent::_toHtml(); | ||
} | ||
|
||
/** | ||
* @return StoreInterface|null | ||
*/ | ||
private function getCurrentStore() | ||
{ | ||
if (null === $this->currentStore) { | ||
try { | ||
$this->currentStore = $this->_storeManager->getStore(); | ||
} catch (NoSuchEntityException $e) { | ||
$this->_logger->error($e->getMessage()); | ||
} | ||
} | ||
|
||
return $this->currentStore; | ||
} | ||
} |
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,62 @@ | ||
<?php | ||
|
||
namespace Klevu\Search\Block\Search; | ||
|
||
use Klevu\Search\Helper\Config as ConfigHelper; | ||
use Klevu\Search\Model\Source\ThemeVersion; | ||
use Magento\Framework\Exception\NoSuchEntityException; | ||
use Magento\Framework\View\Element\Template; | ||
use Magento\Framework\View\Element\Template\Context; | ||
use Magento\Store\Model\ScopeInterface; | ||
|
||
class CssIncludes extends Template | ||
{ | ||
/** | ||
* @var ConfigHelper | ||
*/ | ||
private $configHelper; | ||
|
||
/** | ||
* @param Context $context | ||
* @param ConfigHelper $configHelper | ||
* @param array $data | ||
*/ | ||
public function __construct( | ||
Context $context, | ||
ConfigHelper $configHelper, | ||
array $data = [] | ||
) { | ||
parent::__construct($context, $data); | ||
|
||
$this->configHelper = $configHelper; | ||
} | ||
|
||
/** | ||
* {@inheritdoc} | ||
* @return string | ||
*/ | ||
protected function _toHtml() | ||
{ | ||
try { | ||
$store = $this->_storeManager->getStore(); | ||
$storeId = (int)$store->getId(); | ||
} catch (NoSuchEntityException $e) { | ||
$this->_logger->error($e->getMessage()); | ||
|
||
return ''; | ||
} | ||
|
||
$themeVersion = $this->_scopeConfig->getValue( | ||
ConfigHelper::XML_PATH_THEME_VERSION, | ||
ScopeInterface::SCOPE_STORES, | ||
$storeId | ||
); | ||
|
||
if ((ThemeVersion::V2 === $themeVersion) | ||
|| !$this->configHelper->isExtensionConfigured($storeId)) { | ||
return ''; | ||
} | ||
|
||
return parent::_toHtml(); | ||
} | ||
} |
Oops, something went wrong.