Skip to content

Commit 35a54ff

Browse files
author
Dair Baidauletov
authored
Merge pull request #152 from Nosto/release/4.0.0
4.0.0 release
2 parents fe7b386 + d3fa0a9 commit 35a54ff

38 files changed

+747
-1621
lines changed

Block/SortOrder.php

+43-8
Original file line numberDiff line numberDiff line change
@@ -36,41 +36,76 @@
3636

3737
namespace Nosto\Cmp\Block;
3838

39+
use Magento\Catalog\Model\Category;
40+
use Magento\Framework\App\Request\Http;
41+
use /** @noinspection PhpDeprecationInspection */ Magento\Framework\Registry;
3942
use Magento\Framework\View\Element\Template;
4043
use Magento\Framework\View\Element\Template\Context;
4144
use Nosto\Cmp\Helper\CategorySorting;
42-
use Nosto\Cmp\Plugin\Catalog\Block\ParameterResolverInterface;
4345
use Nosto\Model\SortOrder as NostoSortOrder;
4446
use Nosto\Tagging\Block\TaggingTrait;
4547
use Nosto\Tagging\Helper\Account as NostoHelperAccount;
4648
use Nosto\Tagging\Helper\Scope as NostoHelperScope;
4749

4850
class SortOrder extends Template
4951
{
52+
const DEFAULT_SORTING_ORDER_PARAM = 'product_list_order';
5053

5154
use TaggingTrait {
5255
TaggingTrait::__construct as taggingConstruct; // @codingStandardsIgnoreLine
5356
}
5457

55-
/** @var ParameterResolverInterface */
56-
private $parameterResolver;
58+
/** @var Http */
59+
private $httpRequest;
60+
61+
/** @var Registry */
62+
private $registry;
5763

5864
/**
5965
* SortOrder constructor.
6066
* @param Context $context
61-
* @param ParameterResolverInterface $parameterResolver
67+
* @param Http $httpRequest
68+
* @param Registry $registry
6269
* @param NostoHelperAccount $nostoHelperAccount
6370
* @param NostoHelperScope $nostoHelperScope
71+
* @noinspection PhpDeprecationInspection
72+
* @noinspection PhpUnused
6473
*/
6574
public function __construct(
6675
Context $context,
67-
ParameterResolverInterface $parameterResolver,
76+
Http $httpRequest,
77+
Registry $registry,
6878
NostoHelperAccount $nostoHelperAccount,
6979
NostoHelperScope $nostoHelperScope
7080
) {
7181
parent::__construct($context);
7282
$this->taggingConstruct($nostoHelperAccount, $nostoHelperScope);
73-
$this->parameterResolver = $parameterResolver;
83+
$this->httpRequest = $httpRequest;
84+
$this->registry = $registry;
85+
}
86+
87+
/**
88+
* Returns default category sorting order
89+
*
90+
* @return string
91+
*/
92+
public function getDefaultCategorySorting()
93+
{
94+
/**
95+
* @var Category $category
96+
* @noinspection PhpDeprecationInspection
97+
*/
98+
$category = $this->registry->registry('current_category'); //@phan-suppress-current-line PhanDeprecatedFunction
99+
$sortBy = null;
100+
101+
if ($category instanceof Category) {
102+
$sortBy = $category->getDefaultSortBy();
103+
}
104+
105+
return $this->httpRequest->getParam(
106+
self::DEFAULT_SORTING_ORDER_PARAM,
107+
$sortBy
108+
);
74109
}
75110

76111
/**
@@ -80,10 +115,10 @@ public function __construct(
80115
*/
81116
private function getSortOrder()
82117
{
83-
if ($this->parameterResolver->getSortingOrder() === CategorySorting::NOSTO_PERSONALIZED_KEY) {
118+
if ($this->getDefaultCategorySorting() === CategorySorting::NOSTO_PERSONALIZED_KEY) {
84119
return NostoSortOrder::CMP_VALUE;
85120
}
86-
return $this->parameterResolver->getSortingOrder();
121+
return $this->getDefaultCategorySorting();
87122
}
88123

89124
/**

CHANGELOG.md

+5
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,10 @@
11
All notable changes to this project will be documented in this file. This project adheres to Semantic Versioning.
22

3+
### 4.0.0
4+
* Remove support for MySQL as search engine
5+
* Move CategoryMerchandising util to php-sdk
6+
* Refactor Merchandise service
7+
38
### 3.3.3
49
* Fix fallback sorting issue on GraphQl when merchandising is not enabled
510

Original file line numberDiff line numberDiff line change
@@ -0,0 +1,225 @@
1+
<?php
2+
/**
3+
* Copyright (c) 2020, Nosto Solutions Ltd
4+
* All rights reserved.
5+
*
6+
* Redistribution and use in source and binary forms, with or without modification,
7+
* are permitted provided that the following conditions are met:
8+
*
9+
* 1. Redistributions of source code must retain the above copyright notice,
10+
* this list of conditions and the following disclaimer.
11+
*
12+
* 2. Redistributions in binary form must reproduce the above copyright notice,
13+
* this list of conditions and the following disclaimer in the documentation
14+
* and/or other materials provided with the distribution.
15+
*
16+
* 3. Neither the name of the copyright holder nor the names of its contributors
17+
* may be used to endorse or promote products derived from this software without
18+
* specific prior written permission.
19+
*
20+
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
21+
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
22+
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
23+
* DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR
24+
* ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
25+
* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
26+
* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
27+
* ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
28+
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
29+
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
30+
*
31+
* @author Nosto Solutions Ltd <[email protected]>
32+
* @copyright 2020 Nosto Solutions Ltd
33+
* @license http://opensource.org/licenses/BSD-3-Clause BSD 3-Clause
34+
*
35+
*/
36+
37+
namespace Nosto\Cmp\Model\Merchandise;
38+
39+
use Nosto\Cmp\Model\Facet\FacetInterface;
40+
use Nosto\Types\Signup\AccountInterface;
41+
42+
class MerchandiseRequestParams
43+
{
44+
/** @var AccountInterface */
45+
private $nostoAccount;
46+
47+
/** @var FacetInterface */
48+
private $facets;
49+
50+
/** @var string */
51+
private $customerId;
52+
53+
/** @var string */
54+
private $category;
55+
56+
/** @var int */
57+
private $pageNumber;
58+
59+
/** @var int */
60+
private $limit;
61+
62+
/** @var bool */
63+
private $previewMode;
64+
65+
/** @var string */
66+
private $batchToken;
67+
68+
/**
69+
* @param AccountInterface $nostoAccount
70+
* @param FacetInterface $facets
71+
* @param string $customerId
72+
* @param string $category
73+
* @param int $pageNumber
74+
* @param int $limit
75+
* @param bool $previewMode
76+
* @param string $batchToken
77+
*/
78+
public function __construct(
79+
AccountInterface $nostoAccount,
80+
FacetInterface $facets,
81+
string $customerId,
82+
string $category,
83+
int $pageNumber,
84+
int $limit,
85+
bool $previewMode,
86+
string $batchToken
87+
) {
88+
$this->nostoAccount = $nostoAccount;
89+
$this->facets = $facets;
90+
$this->customerId = $customerId;
91+
$this->category = $category;
92+
$this->pageNumber = $pageNumber;
93+
$this->limit = $limit;
94+
$this->previewMode = $previewMode;
95+
$this->batchToken = $batchToken;
96+
}
97+
98+
/**
99+
* @return AccountInterface
100+
*/
101+
public function getNostoAccount(): AccountInterface
102+
{
103+
return $this->nostoAccount;
104+
}
105+
106+
/**
107+
* @param AccountInterface $nostoAccount
108+
*/
109+
public function setNostoAccount(AccountInterface $nostoAccount): void
110+
{
111+
$this->nostoAccount = $nostoAccount;
112+
}
113+
114+
/**
115+
* @return FacetInterface
116+
*/
117+
public function getFacets(): FacetInterface
118+
{
119+
return $this->facets;
120+
}
121+
122+
/**
123+
* @param FacetInterface $facets
124+
*/
125+
public function setFacets(FacetInterface $facets): void
126+
{
127+
$this->facets = $facets;
128+
}
129+
130+
/**
131+
* @return string
132+
*/
133+
public function getCustomerId(): string
134+
{
135+
return $this->customerId;
136+
}
137+
138+
/**
139+
* @param string $customerId
140+
*/
141+
public function setCustomerId(string $customerId): void
142+
{
143+
$this->customerId = $customerId;
144+
}
145+
146+
/**
147+
* @return string
148+
*/
149+
public function getCategory(): string
150+
{
151+
return $this->category;
152+
}
153+
154+
/**
155+
* @param string $category
156+
*/
157+
public function setCategory(string $category): void
158+
{
159+
$this->category = $category;
160+
}
161+
162+
/**
163+
* @return int
164+
*/
165+
public function getPageNumber(): int
166+
{
167+
return $this->pageNumber;
168+
}
169+
170+
/**
171+
* @param int $pageNumber
172+
*/
173+
public function setPageNumber(int $pageNumber): void
174+
{
175+
$this->pageNumber = $pageNumber;
176+
}
177+
178+
/**
179+
* @return int
180+
*/
181+
public function getLimit(): int
182+
{
183+
return $this->limit;
184+
}
185+
186+
/**
187+
* @param int $limit
188+
*/
189+
public function setLimit(int $limit): void
190+
{
191+
$this->limit = $limit;
192+
}
193+
194+
/**
195+
* @return bool
196+
*/
197+
public function isPreviewMode(): bool
198+
{
199+
return $this->previewMode;
200+
}
201+
202+
/**
203+
* @param bool $previewMode
204+
*/
205+
public function setPreviewMode(bool $previewMode): void
206+
{
207+
$this->previewMode = $previewMode;
208+
}
209+
210+
/**
211+
* @return string
212+
*/
213+
public function getBatchToken(): string
214+
{
215+
return $this->batchToken;
216+
}
217+
218+
/**
219+
* @param string $batchToken
220+
*/
221+
public function setBatchToken(string $batchToken): void
222+
{
223+
$this->batchToken = $batchToken;
224+
}
225+
}

Model/Service/Recommendation/BatchModel.php Model/Service/MagentoSession/BatchModel.php

+9-5
Original file line numberDiff line numberDiff line change
@@ -34,9 +34,13 @@
3434
*
3535
*/
3636

37-
namespace Nosto\Cmp\Model\Service\Recommendation;
37+
namespace Nosto\Cmp\Model\Service\MagentoSession;
3838

39-
class BatchModel implements BatchModelInterface
39+
/**
40+
* This classed is used to pass around the BatchToken returned from Nosto
41+
* in order to improve performance during pagination
42+
*/
43+
class BatchModel
4044
{
4145
/** @var string */
4246
private $batchToken;
@@ -51,17 +55,17 @@ class BatchModel implements BatchModelInterface
5155
private $totalCount;
5256

5357
/**
54-
* @inheritDoc
58+
* @return int
5559
*/
5660
public function getLastUsedLimit(): int
5761
{
5862
return $this->lastUsedLimit;
5963
}
6064

6165
/**
62-
* @inheritDoc
66+
* @return string
6367
*/
64-
public function getBatchToken(): ?string
68+
public function getBatchToken(): string
6569
{
6670
return $this->batchToken;
6771
}

Model/Service/Recommendation/GraphQlParamModel.php Model/Service/MagentoSession/GraphQlParamModel.php

+1-1
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@
3434
*
3535
*/
3636

37-
namespace Nosto\Cmp\Model\Service\Recommendation;
37+
namespace Nosto\Cmp\Model\Service\MagentoSession;
3838

3939
class GraphQlParamModel
4040
{

Model/Service/Recommendation/SessionService.php Model/Service/MagentoSession/SessionService.php

+1-1
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@
3535
*
3636
*/
3737

38-
namespace Nosto\Cmp\Model\Service\Recommendation;
38+
namespace Nosto\Cmp\Model\Service\MagentoSession;
3939

4040
use Magento\Framework\Session\SessionManagerInterface;
4141

0 commit comments

Comments
 (0)