Skip to content

Commit

Permalink
Merge pull request #8 from delyriand/fix-grid-perf
Browse files Browse the repository at this point in the history
Fix grid preformances
  • Loading branch information
romainruaud authored Mar 30, 2018
2 parents db65dd3 + 6f96084 commit 412b6ea
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 6 deletions.
9 changes: 5 additions & 4 deletions Model/ResourceModel/Offer/Collection.php
Original file line number Diff line number Diff line change
Expand Up @@ -87,12 +87,13 @@ public function addSellerTypeFilter($sellerEntity)
$sellerPkName = $sellerMetadata->getIdentifierField();

if (null !== $attributeSetId) {
$this->getSelect()->joinInner(
$this->getSelect()->joinLeft(
$this->getTable($sellerTable),
new \Zend_Db_Expr("{$sellerTable}.{$sellerPkName} = main_table." . OfferInterface::SELLER_ID)
implode(' AND ', [
new \Zend_Db_Expr("{$sellerTable}.{$sellerPkName} = main_table." . OfferInterface::SELLER_ID),
new \Zend_Db_Expr("{$sellerTable}.attribute_set_id = ". (int) $attributeSetId),
])
);

$this->getSelect()->where("{$sellerTable}.attribute_set_id = ?", (int) $attributeSetId);
}
}
}
Expand Down
13 changes: 11 additions & 2 deletions Model/ResourceModel/Offer/Grid/Collection.php
Original file line number Diff line number Diff line change
Expand Up @@ -159,7 +159,13 @@ public function addEntityAttributeToSelect($entityType, $attributeCode, $alias =
// Join entity attribute value table.
$this->getSelect()->joinLeft(
["{$attributeTableAlias}_d" => $this->getTable($backendTable)],
new \Zend_Db_Expr("{$attributeTableAlias}_d.{$linkField} = main_table.{$foreignKey}"),
implode(
' AND ',
[
new \Zend_Db_Expr("{$attributeTableAlias}_d.{$linkField} = main_table.{$foreignKey}"),
new \Zend_Db_Expr("{$attributeTableAlias}_d.attribute_id = ".$attribute->getId()),
]
),
$columns
);

Expand All @@ -174,7 +180,10 @@ public function addEntityAttributeToSelect($entityType, $attributeCode, $alias =
];

$this->getSelect()->joinLeft(["{$attributeTableAlias}_s" => $backendTable], implode(' AND ', $joinCondition), []);
$storeCondition = $this->getConnection()->getIfNullSql("{$attributeTableAlias}_s.store_id", \Magento\Store\Model\Store::DEFAULT_STORE_ID);
$storeCondition = $this->getConnection()->getIfNullSql(
"{$attributeTableAlias}_s.store_id",
\Magento\Store\Model\Store::DEFAULT_STORE_ID
);
}

$this->getSelect()->where("{$attributeTableAlias}_d.store_id = ?", $storeCondition);
Expand Down

0 comments on commit 412b6ea

Please sign in to comment.