Skip to content

Probably unnecessary use of around plugin #27912

Open
@lbajsarowicz

Description

@lbajsarowicz

As a part of improving performance and Developer Experience, Magento should reduce the use of around plugins. The ticket mentions some of these, as a "TODO" list to handle in near future.

public function aroundSave(
GroupRepositoryInterface $subject,
\Closure $proceed,
GroupInterface $group
) {
$isGroupNew = $group->getId() === null;
$group = $proceed($group);
if ($isGroupNew) {
foreach ($this->getAffectedDimensions((string)$group->getId()) as $dimensions) {
$this->tableMaintainer->createTablesForDimensions($dimensions);
}
}
$this->updateIndex->update($group, $isGroupNew);
return $group;
}

public function aroundSave(StoreWebsite $subject, \Closure $proceed)
{
$isObjectNew = $subject->getId() == 0;
$result = $proceed();
if ($isObjectNew) {
$this->indexerRegistry->get(Config::DESIGN_CONFIG_GRID_INDEXER_ID)->invalidate();
}
return $result;
}

public function aroundSave(StoreStore $subject, \Closure $proceed)
{
$isObjectNew = $subject->getId() == 0;
$result = $proceed();
if ($isObjectNew) {
$this->indexerRegistry->get(Config::DESIGN_CONFIG_GRID_INDEXER_ID)->invalidate();
}
return $result;
}

public function aroundSave(
\Magento\Catalog\Model\ResourceModel\Attribute $subject,
\Closure $proceed,
\Magento\Framework\Model\AbstractModel $attribute
) {
$isNew = $attribute->isObjectNew();
$isWeightChanged = $attribute->dataHasChangedFor('search_weight');
$result = $proceed($attribute);
if ($isNew || $isWeightChanged) {
$this->config->reset();
}
return $result;
}

public function aroundDelete(
\Magento\Catalog\Model\ResourceModel\Category $subject,
\Closure $proceed,
\Magento\Catalog\Api\Data\CategoryInterface $category
) {
$categoryIds = $this->childrenCategoriesProvider->getChildrenIds($category, true);
$categoryIds[] = $category->getId();
$result = $proceed($category);
foreach ($categoryIds as $categoryId) {
$this->deleteRewritesForCategory($categoryId);
}
return $result;
}

public function aroundDelete(
\Magento\Catalog\Model\ResourceModel\Product $subject,
\Closure $proceed,
\Magento\Catalog\Model\Product $product
) {
$configurableProductIds = $this->configurable->getParentIdsByChild($product->getId());
$result = $proceed($product);
$this->productIndexer->executeList($configurableProductIds);
return $result;
}

Summary (*)

Examples (*)

Proposed solution

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    Status

    Ready for Grooming

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions