Skip to content

Commit

Permalink
#100331 Added numeric product SKU validation
Browse files Browse the repository at this point in the history
There are some places where product ID might be passed instead of SKU
  • Loading branch information
Jose Ortega committed Jul 24, 2023
1 parent edd97ae commit ff3df1a
Showing 1 changed file with 9 additions and 0 deletions.
9 changes: 9 additions & 0 deletions Model/ImportExport/Processor/Import/Node/Type/Catalog.php
Original file line number Diff line number Diff line change
Expand Up @@ -74,6 +74,15 @@ public function getCategory($categoryId): ?CategoryInterface
*/
public function getProduct($sku): ?ProductInterface
{
if (is_numeric($sku)) {
try {
$product = $this->productRepository->getById((int) $sku);
$sku = $product->getSku();
} catch (NoSuchEntityException $exception) {
// nothing to do here
}
}

if (isset($this->cachedProducts[$sku])) {
return $this->cachedProducts[$sku];
}
Expand Down

0 comments on commit ff3df1a

Please sign in to comment.