Skip to content

Commit 6a52eba

Browse files
authored
Merge pull request #7362 from magento-l3/PR-2021-12-21
PR-2021-12-21
2 parents 1207212 + 3c4e5e2 commit 6a52eba

File tree

23 files changed

+1009
-119
lines changed

23 files changed

+1009
-119
lines changed

app/code/Magento/CatalogGraphQl/Model/Resolver/Categories/DataProvider/Category/CollectionProcessor/CatalogProcessor.php

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,27 @@ public function process(
4949
ContextInterface $context = null
5050
): Collection {
5151
$this->collectionProcessor->process($searchCriteria, $collection);
52+
$store = $context->getExtensionAttributes()->getStore();
53+
$this->addRootCategoryFilterForStore($collection, (string) $store->getRootCategoryId());
5254

5355
return $collection;
5456
}
57+
58+
/**
59+
* Add filtration based on the store root category id
60+
*
61+
* @param Collection $collection
62+
* @param string $rootCategoryId
63+
*/
64+
private function addRootCategoryFilterForStore(Collection $collection, string $rootCategoryId) : void
65+
{
66+
$select = $collection->getSelect();
67+
$connection = $collection->getConnection();
68+
$select->where(
69+
$connection->quoteInto(
70+
'e.path LIKE ? OR e.entity_id=' . $connection->quote($rootCategoryId, 'int'),
71+
'%/' . $rootCategoryId . '/%'
72+
)
73+
);
74+
}
5575
}

app/code/Magento/Cms/Model/ResourceModel/Block/Grid/Collection.php

Lines changed: 53 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -8,48 +8,65 @@
88
use Magento\Framework\Api\Search\SearchResultInterface;
99
use Magento\Framework\Api\Search\AggregationInterface;
1010
use Magento\Cms\Model\ResourceModel\Block\Collection as BlockCollection;
11+
use Magento\Framework\App\ObjectManager;
12+
use Magento\Framework\Data\Collection\Db\FetchStrategyInterface;
13+
use Magento\Framework\Data\Collection\EntityFactoryInterface;
14+
use Magento\Framework\DB\Adapter\AdapterInterface;
15+
use Magento\Framework\EntityManager\MetadataPool;
16+
use Magento\Framework\Event\ManagerInterface;
17+
use Magento\Framework\Model\ResourceModel\Db\AbstractDb;
18+
use Magento\Framework\Stdlib\DateTime\TimezoneInterface;
19+
use Magento\Store\Model\StoreManagerInterface;
20+
use Psr\Log\LoggerInterface;
1121

1222
/**
1323
* Collection for displaying grid of cms blocks
1424
*/
1525
class Collection extends BlockCollection implements SearchResultInterface
1626
{
27+
/**
28+
* @var TimezoneInterface
29+
*/
30+
private $timeZone;
31+
1732
/**
1833
* @var AggregationInterface
1934
*/
2035
protected $aggregations;
2136

2237
/**
23-
* @param \Magento\Framework\Data\Collection\EntityFactoryInterface $entityFactory
24-
* @param \Psr\Log\LoggerInterface $logger
25-
* @param \Magento\Framework\Data\Collection\Db\FetchStrategyInterface $fetchStrategy
26-
* @param \Magento\Framework\Event\ManagerInterface $eventManager
27-
* @param \Magento\Store\Model\StoreManagerInterface $storeManager
28-
* @param \Magento\Framework\EntityManager\MetadataPool $metadataPool
38+
* @param EntityFactoryInterface $entityFactory
39+
* @param LoggerInterface $logger
40+
* @param FetchStrategyInterface $fetchStrategy
41+
* @param ManagerInterface $eventManager
42+
* @param StoreManagerInterface $storeManager
43+
* @param MetadataPool $metadataPool
2944
* @param string $mainTable
3045
* @param string $eventPrefix
3146
* @param string $eventObject
3247
* @param string $resourceModel
3348
* @param string $model
34-
* @param \Magento\Framework\DB\Adapter\AdapterInterface|string|null $connection
35-
* @param \Magento\Framework\Model\ResourceModel\Db\AbstractDb $resource
49+
* @param AdapterInterface|string|null $connection
50+
* @param AbstractDb $resource
51+
* @param TimezoneInterface|null $timeZone
3652
*
3753
* @SuppressWarnings(PHPMD.ExcessiveParameterList)
3854
*/
3955
public function __construct(
40-
\Magento\Framework\Data\Collection\EntityFactoryInterface $entityFactory,
41-
\Psr\Log\LoggerInterface $logger,
42-
\Magento\Framework\Data\Collection\Db\FetchStrategyInterface $fetchStrategy,
43-
\Magento\Framework\Event\ManagerInterface $eventManager,
44-
\Magento\Store\Model\StoreManagerInterface $storeManager,
45-
\Magento\Framework\EntityManager\MetadataPool $metadataPool,
56+
EntityFactoryInterface $entityFactory,
57+
LoggerInterface $logger,
58+
FetchStrategyInterface $fetchStrategy,
59+
ManagerInterface $eventManager,
60+
StoreManagerInterface $storeManager,
61+
MetadataPool $metadataPool,
4662
$mainTable,
4763
$eventPrefix,
4864
$eventObject,
4965
$resourceModel,
5066
$model = \Magento\Framework\View\Element\UiComponent\DataProvider\Document::class,
5167
$connection = null,
52-
\Magento\Framework\Model\ResourceModel\Db\AbstractDb $resource = null
68+
AbstractDb $resource = null,
69+
TimezoneInterface $timeZone = null
5370
) {
5471
parent::__construct(
5572
$entityFactory,
@@ -65,9 +82,28 @@ public function __construct(
6582
$this->_eventObject = $eventObject;
6683
$this->_init($model, $resourceModel);
6784
$this->setMainTable($mainTable);
85+
$this->timeZone = $timeZone ?: ObjectManager::getInstance()->get(TimezoneInterface::class);
6886
}
6987

7088
/**
89+
* @inheritDoc
90+
*/
91+
public function addFieldToFilter($field, $condition = null)
92+
{
93+
if ($field === 'creation_time' || $field === 'update_time') {
94+
if (is_array($condition)) {
95+
foreach ($condition as $key => $value) {
96+
$condition[$key] = $this->timeZone->convertConfigTimeToUtc($value);
97+
}
98+
}
99+
}
100+
101+
return parent::addFieldToFilter($field, $condition);
102+
}
103+
104+
/**
105+
* Get aggregation interface instance
106+
*
71107
* @return AggregationInterface
72108
*/
73109
public function getAggregations()
@@ -76,6 +112,8 @@ public function getAggregations()
76112
}
77113

78114
/**
115+
* Set aggregation interface instance
116+
*
79117
* @param AggregationInterface $aggregations
80118
* @return $this
81119
*/

app/code/Magento/Cms/Model/ResourceModel/Page/Grid/Collection.php

Lines changed: 52 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -8,49 +8,65 @@
88
use Magento\Framework\Api\Search\SearchResultInterface;
99
use Magento\Framework\Api\Search\AggregationInterface;
1010
use Magento\Cms\Model\ResourceModel\Page\Collection as PageCollection;
11+
use Magento\Framework\App\ObjectManager;
12+
use Magento\Framework\Data\Collection\Db\FetchStrategyInterface;
13+
use Magento\Framework\Data\Collection\EntityFactoryInterface;
14+
use Magento\Framework\EntityManager\MetadataPool;
15+
use Magento\Framework\Event\ManagerInterface;
16+
use Magento\Framework\Model\ResourceModel\Db\AbstractDb;
17+
use Magento\Framework\Stdlib\DateTime\TimezoneInterface;
18+
use Magento\Store\Model\StoreManagerInterface;
19+
use Psr\Log\LoggerInterface;
1120

1221
/**
1322
* Class Collection
1423
* Collection for displaying grid of sales documents
1524
*/
1625
class Collection extends PageCollection implements SearchResultInterface
1726
{
27+
/**
28+
* @var TimezoneInterface
29+
*/
30+
private $timeZone;
31+
1832
/**
1933
* @var AggregationInterface
2034
*/
2135
protected $aggregations;
2236

2337
/**
24-
* @param \Magento\Framework\Data\Collection\EntityFactoryInterface $entityFactory
25-
* @param \Psr\Log\LoggerInterface $logger
26-
* @param \Magento\Framework\Data\Collection\Db\FetchStrategyInterface $fetchStrategy
27-
* @param \Magento\Framework\Event\ManagerInterface $eventManager
28-
* @param \Magento\Store\Model\StoreManagerInterface $storeManager
29-
* @param \Magento\Framework\EntityManager\MetadataPool $metadataPool
38+
* @param EntityFactoryInterface $entityFactory
39+
* @param LoggerInterface $logger
40+
* @param FetchStrategyInterface $fetchStrategy
41+
* @param ManagerInterface $eventManager
42+
* @param StoreManagerInterface $storeManager
43+
* @param MetadataPool $metadataPool
3044
* @param mixed|null $mainTable
3145
* @param string $eventPrefix
3246
* @param mixed $eventObject
3347
* @param mixed $resourceModel
3448
* @param string $model
35-
* @param null $connection
36-
* @param \Magento\Framework\Model\ResourceModel\Db\AbstractDb|null $resource
49+
* @param mixed|null $connection
50+
* @param AbstractDb|null $resource
51+
* @param TimezoneInterface|null $timeZone
3752
*
3853
* @SuppressWarnings(PHPMD.ExcessiveParameterList)
3954
*/
4055
public function __construct(
41-
\Magento\Framework\Data\Collection\EntityFactoryInterface $entityFactory,
42-
\Psr\Log\LoggerInterface $logger,
43-
\Magento\Framework\Data\Collection\Db\FetchStrategyInterface $fetchStrategy,
44-
\Magento\Framework\Event\ManagerInterface $eventManager,
45-
\Magento\Store\Model\StoreManagerInterface $storeManager,
46-
\Magento\Framework\EntityManager\MetadataPool $metadataPool,
56+
EntityFactoryInterface $entityFactory,
57+
LoggerInterface $logger,
58+
FetchStrategyInterface $fetchStrategy,
59+
ManagerInterface $eventManager,
60+
StoreManagerInterface $storeManager,
61+
MetadataPool $metadataPool,
4762
$mainTable,
4863
$eventPrefix,
4964
$eventObject,
5065
$resourceModel,
5166
$model = \Magento\Framework\View\Element\UiComponent\DataProvider\Document::class,
5267
$connection = null,
53-
\Magento\Framework\Model\ResourceModel\Db\AbstractDb $resource = null
68+
AbstractDb $resource = null,
69+
TimezoneInterface $timeZone = null
5470
) {
5571
parent::__construct(
5672
$entityFactory,
@@ -66,9 +82,28 @@ public function __construct(
6682
$this->_eventObject = $eventObject;
6783
$this->_init($model, $resourceModel);
6884
$this->setMainTable($mainTable);
85+
$this->timeZone = $timeZone ?: ObjectManager::getInstance()->get(TimezoneInterface::class);
6986
}
7087

7188
/**
89+
* @inheritDoc
90+
*/
91+
public function addFieldToFilter($field, $condition = null)
92+
{
93+
if ($field === 'creation_time' || $field === 'update_time') {
94+
if (is_array($condition)) {
95+
foreach ($condition as $key => $value) {
96+
$condition[$key] = $this->timeZone->convertConfigTimeToUtc($value);
97+
}
98+
}
99+
}
100+
101+
return parent::addFieldToFilter($field, $condition);
102+
}
103+
104+
/**
105+
* Get aggregation interface instance
106+
*
72107
* @return AggregationInterface
73108
*/
74109
public function getAggregations()
@@ -77,6 +112,8 @@ public function getAggregations()
77112
}
78113

79114
/**
115+
* Set aggregation interface instance
116+
*
80117
* @param AggregationInterface $aggregations
81118
* @return $this
82119
*/

app/code/Magento/ConfigurableProduct/Model/Product/Type/Configurable.php

Lines changed: 5 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ class Configurable extends \Magento\Catalog\Model\Product\Type\AbstractType
3636
/**
3737
* Product type code
3838
*/
39-
const TYPE_CODE = 'configurable';
39+
public const TYPE_CODE = 'configurable';
4040

4141
/**
4242
* Cache key for Used Product Attribute Ids
@@ -117,45 +117,32 @@ class Configurable extends \Magento\Catalog\Model\Product\Type\AbstractType
117117
protected $_scopeConfig;
118118

119119
/**
120-
* Catalog product type configurable
121-
*
122120
* @var \Magento\ConfigurableProduct\Model\ResourceModel\Product\Type\Configurable
123121
*/
124122
protected $_catalogProductTypeConfigurable;
125123

126124
/**
127-
* Attribute collection factory
128-
*
129-
* @var
130-
* \Magento\ConfigurableProduct\Model\ResourceModel\Product\Type\Configurable\Attribute\CollectionFactory
125+
* @var \Magento\ConfigurableProduct\Model\ResourceModel\Product\Type\Configurable\Attribute\CollectionFactory
131126
*/
132127
protected $_attributeCollectionFactory;
133128

134129
/**
135-
* Product collection factory
136-
*
137130
* @var \Magento\ConfigurableProduct\Model\ResourceModel\Product\Type\Configurable\Product\CollectionFactory
138131
*/
139132
protected $_productCollectionFactory;
140133

141134
/**
142-
* Configurable attribute factory
143-
*
144135
* @var \Magento\ConfigurableProduct\Model\Product\Type\Configurable\AttributeFactory
145136
* @since 100.1.0
146137
*/
147138
protected $configurableAttributeFactory;
148139

149140
/**
150-
* Eav attribute factory
151-
*
152141
* @var \Magento\Catalog\Model\ResourceModel\Eav\AttributeFactory
153142
*/
154143
protected $_eavAttributeFactory;
155144

156145
/**
157-
* Type configurable factory
158-
*
159146
* @var \Magento\ConfigurableProduct\Model\ResourceModel\Product\Type\ConfigurableFactory
160147
* @since 100.1.0
161148
*/
@@ -192,8 +179,6 @@ class Configurable extends \Magento\Catalog\Model\Product\Type\AbstractType
192179
private $customerSession;
193180

194181
/**
195-
* Product factory
196-
*
197182
* @var ProductInterfaceFactory
198183
*/
199184
private $productFactory;
@@ -772,6 +757,9 @@ public function isSalable($product)
772757
if ($storeId instanceof \Magento\Store\Model\Store) {
773758
$storeId = $storeId->getId();
774759
}
760+
if ($storeId === null && $product->getStoreId()) {
761+
$storeId = $product->getStoreId();
762+
}
775763

776764
$sku = $product->getSku();
777765
if (isset($this->isSaleableBySku[$storeId][$sku])) {

0 commit comments

Comments
 (0)