Skip to content

Commit

Permalink
Merge pull request #90 from Nosto/release/3.0.0
Browse files Browse the repository at this point in the history
Release/3.0.0
  • Loading branch information
olsi-qose authored Feb 18, 2021
2 parents 8af6740 + 8d9f7fc commit 3ef35a5
Show file tree
Hide file tree
Showing 43 changed files with 1,528 additions and 320 deletions.
15 changes: 9 additions & 6 deletions .github/workflows/action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,8 @@ jobs:
uses: shivammathur/setup-php@v2
with:
php-version: '7.2'
tools: composer, prestissimo
extensions: ast
tools: composer:v1, prestissimo
extensions: ast, bcmath, gd
coverage: none

#https://github.com/actions/cache/blob/master/examples.md#php---composer
Expand Down Expand Up @@ -69,8 +69,8 @@ jobs:
uses: shivammathur/setup-php@v2
with:
php-version: '7.2'
tools: composer, prestissimo
extensions: ast
tools: composer:v1, prestissimo
extensions: ast, bcmath, gd
coverage: none

#https://github.com/actions/cache/blob/master/examples.md#php---composer
Expand Down Expand Up @@ -120,8 +120,8 @@ jobs:
uses: shivammathur/setup-php@v2
with:
php-version: '7.2'
tools: composer, prestissimo
extensions: ast
tools: composer:v1, prestissimo
extensions: ast, bcmath, gd
coverage: none

#https://github.com/actions/cache/blob/master/examples.md#php---composer
Expand All @@ -143,6 +143,9 @@ jobs:
run: |
composer config repositories.0 composer https://repo.magento.com
composer config http-basic.repo.magento.com "$REPO_USR" "$REPO_PSW"
composer require --no-update nosto/module-nostotagging:@stable
composer require --no-update nosto/module-nosto-msi:@stable
composer require --no-update nosto/module-nosto-itp:@stable
composer install --prefer-dist --no-progress --no-suggest
############################################################################

Expand Down
4 changes: 2 additions & 2 deletions .github/workflows/phan.yml
Original file line number Diff line number Diff line change
Expand Up @@ -16,9 +16,9 @@ jobs:
uses: shivammathur/setup-php@v2
with:
php-version: '7.2'
tools: composer, prestissimo, pecl
tools: composer:v1, prestissimo, pecl
extensions: ast, bcmath, gd, pdo_mysql, soap, zip
coverage: none
extensions: ast

- name: Cache composer packages
id: composer-cache
Expand Down
27 changes: 21 additions & 6 deletions Block/CategoryMapping.php
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<?php
/**
* Copyright (c) 2019, Nosto Solutions Ltd
* Copyright (c) 2020, Nosto Solutions Ltd
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without modification,
Expand Down Expand Up @@ -29,7 +29,7 @@
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*
* @author Nosto Solutions Ltd <contact@nosto.com>
* @copyright 2019 Nosto Solutions Ltd
* @copyright 2020 Nosto Solutions Ltd
* @license http://opensource.org/licenses/BSD-3-Clause BSD 3-Clause
*
*/
Expand All @@ -44,8 +44,9 @@
use Magento\Framework\View\Element\Template\Context;
use Magento\Store\Model\Store;
use Magento\Store\Model\StoreManagerInterface;
use Nosto\Tagging\Logger\Logger as NostoLogger;
use Nosto\Cmp\Logger\LoggerInterface;
use Nosto\Tagging\Model\Service\Product\Category\DefaultCategoryService as CategoryBuilder;
use Nosto\Cmp\Helper\Data as NostoHelperData;

class CategoryMapping extends Template
{
Expand All @@ -58,23 +59,34 @@ class CategoryMapping extends Template
/** @var CategoryBuilder */
private $categoryBuilder;

/** @var NostoLogger */
/** @var NostoHelperData */
private $nostoHelperData;

/** @var LoggerInterface */
private $logger;

/**
* CategoryMapping constructor.
* @param StoreManagerInterface $storeManager
* @param CollectionFactory $collectionFactory
* @param CategoryBuilder $categoryBuilder
* @param NostoHelperData $nostoHelperData
* @param Context $context
* @param LoggerInterface $logger
*/
public function __construct(
StoreManagerInterface $storeManager,
CollectionFactory $collectionFactory,
CategoryBuilder $categoryBuilder,
NostoHelperData $nostoHelperData,
Context $context,
NostoLogger $logger
LoggerInterface $logger
) {
parent::__construct($context);
$this->storeManager = $storeManager;
$this->collectionFactory = $collectionFactory;
$this->categoryBuilder = $categoryBuilder;
$this->nostoHelperData = $nostoHelperData;
$this->logger = $logger;
}

Expand Down Expand Up @@ -113,10 +125,13 @@ private function getMagentoCategories(Store $store)

$categories = $this->collectionFactory->create()
->addAttributeToSelect('*')
->addAttributeToFilter('include_in_menu', ['eq' => 1])
->addIsActiveFilter()
->setStore($store);

if (!$this->nostoHelperData->isAllCategoriesMapEnabled($store)) {
$categories->addAttributeToFilter('include_in_menu', ['eq' => 1]);
}

/** @var Category $category $item */
foreach ($categories->getItems() as $category) {
$hashedCategoryString = $this->hashCategoryString(strtolower(
Expand Down
4 changes: 2 additions & 2 deletions Block/SortOrder.php
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<?php
/**
* Copyright (c) 2019, Nosto Solutions Ltd
* Copyright (c) 2020, Nosto Solutions Ltd
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without modification,
Expand Down Expand Up @@ -29,7 +29,7 @@
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*
* @author Nosto Solutions Ltd <contact@nosto.com>
* @copyright 2019 Nosto Solutions Ltd
* @copyright 2020 Nosto Solutions Ltd
* @license http://opensource.org/licenses/BSD-3-Clause BSD 3-Clause
*
*/
Expand Down
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,9 @@
All notable changes to this project will be documented in this file. This project adheres to Semantic Versioning.

### 3.0.0
* Add support for using Elasticsearch as a catalog search engine
* Introduce possibility to use all categories (not only the ones in navigation) with Nosto's category merchandising

### 2.0.3
* Fix the default max product limit configuration and set the default value to be 250 which is the current max products limit in Nosto

Expand Down
4 changes: 2 additions & 2 deletions Helper/CategorySorting.php
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<?php
/**
* Copyright (c) 2019, Nosto Solutions Ltd
* Copyright (c) 2020, Nosto Solutions Ltd
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without modification,
Expand Down Expand Up @@ -29,7 +29,7 @@
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*
* @author Nosto Solutions Ltd <contact@nosto.com>
* @copyright 2019 Nosto Solutions Ltd
* @copyright 2020 Nosto Solutions Ltd
* @license http://opensource.org/licenses/BSD-3-Clause BSD 3-Clause
*
*/
Expand Down
20 changes: 18 additions & 2 deletions Helper/Data.php
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<?php
/**
* Copyright (c) 2019, Nosto Solutions Ltd
* Copyright (c) 2020, Nosto Solutions Ltd
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without modification,
Expand Down Expand Up @@ -29,7 +29,7 @@
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*
* @author Nosto Solutions Ltd <contact@nosto.com>
* @copyright 2019 Nosto Solutions Ltd
* @copyright 2020 Nosto Solutions Ltd
* @license http://opensource.org/licenses/BSD-3-Clause BSD 3-Clause
*
*/
Expand All @@ -55,6 +55,11 @@ class Data extends AbstractHelper
*/
const XML_PATH_CATEGORY_SORTING = 'nosto_cmp/flags/category_sorting';

/**
* Path to the configuration object that stores category sorting
*/
const XML_PATH_CATEGORY_MAPPING = 'nosto_cmp/flags/map_all_categories';

/**
* Path to the configuration object that stores the max limit for products
*/
Expand Down Expand Up @@ -90,6 +95,17 @@ public function isCategorySortingEnabled(StoreInterface $store = null)
return (bool)$this->getStoreConfig(self::XML_PATH_CATEGORY_SORTING, $store);
}

/**
* Returns if category sorting is enabled
*
* @param StoreInterface|null $store the store model or null.
* @return bool the configuration value
*/
public function isAllCategoriesMapEnabled(StoreInterface $store = null)
{
return (bool)$this->getStoreConfig(self::XML_PATH_CATEGORY_MAPPING, $store);
}

/**
* Returns if category sorting is enabled
*
Expand Down
79 changes: 79 additions & 0 deletions Helper/SearchEngine.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,79 @@
<?php
/**
* Copyright (c) 2020, Nosto Solutions Ltd
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without modification,
* are permitted provided that the following conditions are met:
*
* 1. Redistributions of source code must retain the above copyright notice,
* this list of conditions and the following disclaimer.
*
* 2. Redistributions in binary form must reproduce the above copyright notice,
* this list of conditions and the following disclaimer in the documentation
* and/or other materials provided with the distribution.
*
* 3. Neither the name of the copyright holder nor the names of its contributors
* may be used to endorse or promote products derived from this software without
* specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
* DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR
* ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
* ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*
* @author Nosto Solutions Ltd <contact@nosto.com>
* @copyright 2020 Nosto Solutions Ltd
* @license http://opensource.org/licenses/BSD-3-Clause BSD 3-Clause
*
*/

namespace Nosto\Cmp\Helper;

use Magento\Framework\Search\EngineResolverInterface;

class SearchEngine
{
const ENGINE_MYSQL = 'mysql';

/**
* @var EngineResolverInterface
*/
private $engineResolver;

/**
* Data constructor.
* @param EngineResolverInterface $engineResolver
*/
public function __construct(
EngineResolverInterface $engineResolver
) {
$this->engineResolver = $engineResolver;
}

/**
* Returns the current search engine used for catalog search
*
* @return string
*/
public function getCurrentEngine()
{
return $this->engineResolver->getCurrentSearchEngine();
}

/**
* Shortcut method for determining if the engine is MySQL
*
* @return boolean
*/
public function isMysql()
{
return $this->engineResolver->getCurrentSearchEngine() === self::ENGINE_MYSQL;
}
}
56 changes: 56 additions & 0 deletions Logger/Logger.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,56 @@
<?php
/**
* Copyright (c) 2020, Nosto Solutions Ltd
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without modification,
* are permitted provided that the following conditions are met:
*
* 1. Redistributions of source code must retain the above copyright notice,
* this list of conditions and the following disclaimer.
*
* 2. Redistributions in binary form must reproduce the above copyright notice,
* this list of conditions and the following disclaimer in the documentation
* and/or other materials provided with the distribution.
*
* 3. Neither the name of the copyright holder nor the names of its contributors
* may be used to endorse or promote products derived from this software without
* specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
* DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR
* ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
* ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*
* @author Nosto Solutions Ltd <contact@nosto.com>
* @copyright 2020 Nosto Solutions Ltd
* @license http://opensource.org/licenses/BSD-3-Clause BSD 3-Clause
*
*/

namespace Nosto\Cmp\Logger;

use Nosto\Tagging\Logger\Logger as NostoLogger;

class Logger extends NostoLogger implements LoggerInterface
{
/**
* Logs a debug level message with given source class info
*
* @param $message
* @param object $sourceClass
* @param array $context
* @return bool
*/
public function debugCmp($message, $sourceClass, array $context = [])
{
$mergedContext = array_merge(['nosto' => 'cmp'], $context);
return $this->debugWithSource($message, $mergedContext, $sourceClass);
}
}
Loading

0 comments on commit 3ef35a5

Please sign in to comment.