* @copyright Since 2007 PrestaShop SA and Contributors * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) */ namespace PrestaShop\PrestaShop\Adapter\Product\QueryHandler; use PrestaShop\PrestaShop\Adapter\Entity\Product; use PrestaShop\PrestaShop\Core\Domain\Product\Exception\ProductNotFoundException; use PrestaShop\PrestaShop\Core\Domain\Product\Query\GetProductIsEnabled; use PrestaShop\PrestaShop\Core\Domain\Product\QueryHandler\GetProductIsEnabledHandlerInterface; /** * @internal */ final class GetProductIsEnabledHandler implements GetProductIsEnabledHandlerInterface { /** * {@inheritdoc} */ public function handle(GetProductIsEnabled $query) { $productId = $query->getProductId()->getValue(); $product = new Product($productId); if ($product->id !== $productId) { throw new ProductNotFoundException(sprintf('Product with id "%d" was not found.', $productId)); } return (bool) $product->active; } }