-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
FRW-8958 Improved product abstract publishing performance by avoiding…
… joining concretes. (#11114) FRW-8958 Improved product abstract publishing performance by avoiding joining concretes.
- Loading branch information
1 parent
d133506
commit 237d8c9
Showing
10 changed files
with
222 additions
and
16 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
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
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
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
88 changes: 88 additions & 0 deletions
88
src/Spryker/Zed/ProductStorage/Persistence/ProductStorageRepository.php
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,88 @@ | ||
<?php | ||
|
||
/** | ||
* Copyright © 2016-present Spryker Systems GmbH. All rights reserved. | ||
* Use of this software requires acceptance of the Evaluation License Agreement. See LICENSE file. | ||
*/ | ||
|
||
namespace Spryker\Zed\ProductStorage\Persistence; | ||
|
||
use Orm\Zed\Product\Persistence\Map\SpyProductAbstractLocalizedAttributesTableMap; | ||
use Orm\Zed\Url\Persistence\Map\SpyUrlTableMap; | ||
use Propel\Runtime\ActiveQuery\ModelCriteria; | ||
use Spryker\Zed\Kernel\Persistence\AbstractRepository; | ||
|
||
/** | ||
* @method \Spryker\Zed\ProductStorage\Persistence\ProductStoragePersistenceFactory getFactory() | ||
*/ | ||
class ProductStorageRepository extends AbstractRepository implements ProductStorageRepositoryInterface | ||
{ | ||
/** | ||
* @var string | ||
*/ | ||
protected const URL_RELATION = 'SpyProductAbstract.SpyUrl'; | ||
|
||
/** | ||
* @var string | ||
*/ | ||
protected const COLUMN_URL = 'url'; | ||
|
||
/** | ||
* @var string | ||
*/ | ||
protected const ENTITY_URL = 'SpyUrl'; | ||
|
||
/** | ||
* @var string | ||
*/ | ||
protected const COL_PRODUCT_COUNT = 'productCount'; | ||
|
||
/** | ||
* @var string | ||
*/ | ||
protected const COL_FK_PRODUCT_ABSTRACT = 'fk_product_abstract'; | ||
|
||
/** | ||
* @param array<int> $productAbstractIds | ||
* | ||
* @return array<int|string|bool> | ||
*/ | ||
public function getProductAbstractsByIds(array $productAbstractIds): array | ||
{ | ||
return $this->getFactory()->getProductAbstractLocalizedAttributesPropelQuery() | ||
->joinWithLocale() | ||
->joinWithSpyProductAbstract() | ||
->useSpyProductAbstractQuery() | ||
->joinWithSpyProductAbstractStore() | ||
->useSpyProductAbstractStoreQuery() | ||
->joinWithSpyStore() | ||
->endUse() | ||
->endUse() | ||
->filterByFkProductAbstract_In($productAbstractIds) | ||
->setFormatter(ModelCriteria::FORMAT_ARRAY) | ||
->join(static::URL_RELATION) | ||
->addJoinCondition(static::ENTITY_URL, sprintf('%s = %s', SpyUrlTableMap::COL_FK_LOCALE, SpyProductAbstractLocalizedAttributesTableMap::COL_FK_LOCALE)) | ||
->withColumn(SpyUrlTableMap::COL_URL, static::COLUMN_URL) | ||
->find() | ||
->getData(); | ||
} | ||
|
||
/** | ||
* @param array<int> $idProductAbstracts | ||
* | ||
* @return array<array<string, int>> | ||
*/ | ||
public function getProductConcretesCountByIdProductAbstracts(array $idProductAbstracts): array | ||
{ | ||
/** @var \Propel\Runtime\Collection\ObjectCollection $productConcretesCollection */ | ||
$productConcretesCollection = $this->getFactory()->getProductPropelQuery() | ||
->filterByFkProductAbstract_In($idProductAbstracts) | ||
->filterByIsActive(true) | ||
->withColumn('COUNT(*)', static::COL_PRODUCT_COUNT) | ||
->select([static::COL_FK_PRODUCT_ABSTRACT, static::COL_PRODUCT_COUNT]) | ||
->groupByFkProductAbstract() | ||
->find(); | ||
|
||
return $productConcretesCollection->toArray(); | ||
} | ||
} |
28 changes: 28 additions & 0 deletions
28
src/Spryker/Zed/ProductStorage/Persistence/ProductStorageRepositoryInterface.php
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,28 @@ | ||
<?php | ||
|
||
/** | ||
* Copyright © 2016-present Spryker Systems GmbH. All rights reserved. | ||
* Use of this software requires acceptance of the Evaluation License Agreement. See LICENSE file. | ||
*/ | ||
|
||
namespace Spryker\Zed\ProductStorage\Persistence; | ||
|
||
/** | ||
* @method \Spryker\Zed\ProductStorage\Persistence\ProductStoragePersistenceFactory getFactory() | ||
*/ | ||
interface ProductStorageRepositoryInterface | ||
{ | ||
/** | ||
* @param array<int> $productAbstractIds | ||
* | ||
* @return array<mixed> | ||
*/ | ||
public function getProductAbstractsByIds(array $productAbstractIds): array; | ||
|
||
/** | ||
* @param array<int> $idProductAbstract | ||
* | ||
* @return array<array<string, int>> | ||
*/ | ||
public function getProductConcretesCountByIdProductAbstracts(array $idProductAbstract): array; | ||
} |
Oops, something went wrong.