Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Improvement/avoid loading proxy relations data #5

Open
wants to merge 3 commits into
base: 5.1
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
22 changes: 13 additions & 9 deletions ImportExport/Strategy/StrategyRelationsTrait.php
Original file line number Diff line number Diff line change
Expand Up @@ -39,13 +39,6 @@ protected function updateRelations($entity, array $itemData = null)
$isFullRelation = $this->fieldHelper->getConfigValue($entityName, $fieldName, 'full', false);
$isPersistRelation = $this->databaseHelper->isCascadePersist($entityName, $fieldName);

$searchContext = $this->generateSearchContextForRelationsUpdate(
Copy link
Author

@gacek85 gacek85 Mar 6, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

execution of this method causes populating of search context and lazy load proxy for certain properties for all tterated relations - even if the relation entity does not exist. Moving the execution into the if statement AND even deeper into the condition when only the relation exists speeds up the execution very much. It will not be noticible for schemas with ~200 attributes, although for bigger product attributes counts with big set of relations - this is a massive improvement.

$entity,
$entityName,
$fieldName,
$isPersistRelation
);

if ($this->fieldHelper->isSingleRelation($field)) {
// single relation
$relationEntity = $this->getObjectValue($entity, $fieldName);
Expand All @@ -56,16 +49,27 @@ protected function updateRelations($entity, array $itemData = null)
$isFullRelation,
$isPersistRelation,
$relationItemData,
$searchContext,
$this->generateSearchContextForRelationsUpdate(
$entity,
$entityName,
$fieldName,
$isPersistRelation
),
true
);
}
$this->fieldHelper->setObjectValue($entity, $fieldName, $relationEntity);
} elseif ($this->fieldHelper->isMultipleRelation($field)) {
// multiple relation
$relationCollection = $this->getObjectValue($entity, $fieldName);
if ($relationCollection instanceof Collection) {
if (($relationCollection instanceof Collection) && $relationCollection->count()) {
$collectionItemData = $this->fieldHelper->getItemData($itemData, $fieldName);
$searchContext = $this->generateSearchContextForRelationsUpdate(
$entity,
$entityName,
$fieldName,
$isPersistRelation
);
foreach ($relationCollection as $collectionEntity) {
$entityItemData = $this->fieldHelper->getItemData(array_shift($collectionItemData));
$existingCollectionEntity = $this->processEntity(
Expand Down
6 changes: 6 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,11 @@
# Akeneo PIM OroCommerce Connector

## New maintainer

We would like to inform you about the recent transfer of repository maintenance responsibility from OroInc to Creativestyle. This transition aims to enhance the development and support of OroInc projects, providing a seamless experience for users and contributors.

* [creativestyle/OroAkeneoBundle](https://github.com/creativestyle/OroAkeneoBundle)

## Short overview
This extension allows you to connect [OroCommerce Enterprise](https://oroinc.com/b2b-ecommerce/) with [Akeneo PIM Enterprise](https://www.akeneo.com/) and use the latter’s rich capabilities for product information management with your OroCommerce-powered web store. Combine personalized B2B buying experience with compelling product experience to maximize your content marketing ROI and stay ahead of the B2B eCommerce game.

Expand Down