Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save denvit/333c4a0508953acca6772b70d20b931f to your computer and use it in GitHub Desktop.
Save denvit/333c4a0508953acca6772b70d20b931f to your computer and use it in GitHub Desktop.
Solution for Firebear Configurable products NoSuchEntityException on categories
public function afterGetValue(\Magento\ConfigurableProduct\Pricing\Price\FinalPrice $subject, $result)
{
/**
* @todo Add check on whether preselect is enabled
**/
$defaultProductId = $this->defaults->getDefaultProductId($subject->getProduct());
if (!$defaultProductId) {
$defaultProductId = (int) $this->_request->getParam('id');
}
if ($defaultProductId) {
$isCatalogProductView = $this->_request->getControllerName() == 'product';
if ($isCatalogProductView) {
$defaultProduct = $this->productRepository->getById($defaultProductId);
if ($defaultProduct && $defaultProduct->getTypeId() !== 'configurable') {
$result = (float)$defaultProduct->getPrice();
}
}
}
return $result;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment