Skip to content

Commit 0e261c8

Browse files
committed
ACP2E-1243: the catalog_index_refresh_price cron fails with an error that is only reported when run between 0000 and 0059 UTC
1 parent e062546 commit 0e261c8

File tree

1 file changed

+6
-18
lines changed

1 file changed

+6
-18
lines changed

app/code/Magento/Catalog/Cron/RefreshSpecialPrices.php

Lines changed: 6 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,6 @@
66
namespace Magento\Catalog\Cron;
77

88
use Magento\Catalog\Api\Data\CategoryInterface;
9-
use Magento\Framework\App\ObjectManager;
109
use Magento\Framework\App\ResourceConnection;
1110
use Magento\Framework\EntityManager\MetadataPool;
1211

@@ -59,21 +58,24 @@ class RefreshSpecialPrices
5958
* @param \Magento\Framework\Stdlib\DateTime\TimezoneInterface $localeDate
6059
* @param \Magento\Eav\Model\Config $eavConfig
6160
* @param \Magento\Catalog\Model\Indexer\Product\Price\Processor $processor
61+
* @param MetadataPool $metadataPool
6262
*/
6363
public function __construct(
6464
\Magento\Store\Model\StoreManagerInterface $storeManager,
6565
ResourceConnection $resource,
6666
\Magento\Framework\Stdlib\DateTime $dateTime,
6767
\Magento\Framework\Stdlib\DateTime\TimezoneInterface $localeDate,
6868
\Magento\Eav\Model\Config $eavConfig,
69-
\Magento\Catalog\Model\Indexer\Product\Price\Processor $processor
69+
\Magento\Catalog\Model\Indexer\Product\Price\Processor $processor,
70+
MetadataPool $metadataPool
7071
) {
7172
$this->_storeManager = $storeManager;
7273
$this->_resource = $resource;
7374
$this->_dateTime = $dateTime;
7475
$this->_localeDate = $localeDate;
7576
$this->_eavConfig = $eavConfig;
7677
$this->_processor = $processor;
78+
$this->metadataPool = $metadataPool;
7779
}
7880

7981
/**
@@ -139,8 +141,8 @@ protected function _refreshSpecialPriceByStore($storeId, $attrCode, $attrConditi
139141
$attribute = $this->_eavConfig->getAttribute(\Magento\Catalog\Model\Product::ENTITY, $attrCode);
140142
$attributeId = $attribute->getAttributeId();
141143

142-
$linkField = $this->getMetadataPool()->getMetadata(CategoryInterface::class)->getLinkField();
143-
$identifierField = $this->getMetadataPool()->getMetadata(CategoryInterface::class)->getIdentifierField();
144+
$linkField = $this->metadataPool->getMetadata(CategoryInterface::class)->getLinkField();
145+
$identifierField = $this->metadataPool->getMetadata(CategoryInterface::class)->getIdentifierField();
144146

145147
$connection = $this->_getConnection();
146148

@@ -170,18 +172,4 @@ protected function _refreshSpecialPriceByStore($storeId, $attrCode, $attrConditi
170172
$this->_processor->getIndexer()->reindexList($selectData);
171173
}
172174
}
173-
174-
/**
175-
* Get MetadataPool instance
176-
* @return MetadataPool
177-
*
178-
* @deprecated 101.0.0
179-
*/
180-
private function getMetadataPool()
181-
{
182-
if (null === $this->metadataPool) {
183-
$this->metadataPool = ObjectManager::getInstance()->get(MetadataPool::class);
184-
}
185-
return $this->metadataPool;
186-
}
187175
}

0 commit comments

Comments
 (0)