Skip to content

Commit

Permalink
Reduce getId calls (#1571)
Browse files Browse the repository at this point in the history
  • Loading branch information
luigifab authored May 4, 2021
1 parent cc3eff3 commit 266b27d
Showing 1 changed file with 6 additions and 5 deletions.
11 changes: 6 additions & 5 deletions app/code/core/Mage/ConfigurableSwatches/Helper/Mediafallback.php
Original file line number Diff line number Diff line change
Expand Up @@ -322,9 +322,10 @@ public function groupMediaGalleryImages(Mage_Catalog_Model_Product $product)

$newMediaGalleryImages = array();
$configurableImages = array();
$productId = $product->getId();

foreach ($mediaGallery['images'] as $mediaGalleryImage) {
if ($mediaGalleryImage['product_id'] == $product->getId()) {
if ($mediaGalleryImage['product_id'] == $productId) {
$newMediaGalleryImages[] = $mediaGalleryImage;
} else {
$configurableImages[] = $mediaGalleryImage;
Expand Down Expand Up @@ -368,21 +369,21 @@ public function attachGallerySetToCollection(array $products, $storeId)

$relationship = array();
foreach ($products as $product) {
$relationship[$product->getId()] = $product->getId();
$productId = $product->getId();
$relationship[$productId] = $productId;

if (!is_array($product->getChildrenProducts())) {
continue;
}

/* @var Mage_Catalog_Model_Product $childProduct */
foreach ($product->getChildrenProducts() as $childProduct) {
$relationship[$childProduct->getId()] = $product->getId();
$relationship[$childProduct->getId()] = $productId;
}
}

foreach ($images as $image) {
$productId = $image['product_id'];
$realProductId = $relationship[$productId];
$realProductId = $relationship[$image['product_id']];
$product = $products[$realProductId];

if (is_null($image['label'])) {
Expand Down

0 comments on commit 266b27d

Please sign in to comment.