scopeConfig = $scopeConfig; $this->request = $request; $this->_storeManager = $storeManager; $this->productRepository = $productRepository; } /** * Add New Layout handle * * @param \Magento\Framework\Event\Observer $observer * @return self */ public function execute(\Magento\Framework\Event\Observer $observer) { $layout = $observer->getData('layout'); $fullActionName = $observer->getData('full_action_name'); if ($fullActionName != 'weltpixel_quickview_catalog_product_view') { return $this; } $productId= $this->request->getParam('id'); if (isset($productId)) { try { $product = $this->productRepository->getById($productId, false, $this->_storeManager->getStore()->getId()); } catch (NoSuchEntityException $e) { return false; } $productType = $product->getTypeId(); $layout->getUpdate()->addHandle('weltpixel_quickview_catalog_product_view_type_' . $productType); } $removeProductImage = $this->scopeConfig->getValue(self::XML_PATH_QUICKVIEW_REMOVE_PRODUCT_IMAGE, \Magento\Store\Model\ScopeInterface::SCOPE_STORE); if ($removeProductImage) { $layout->getUpdate()->addHandle('weltpixel_quickview_removeproduct_image'); } $removeProductImageThumb = $this->scopeConfig->getValue(self::XML_PATH_QUICKVIEW_REMOVE_PRODUCT_IMAGE_THUMB, \Magento\Store\Model\ScopeInterface::SCOPE_STORE); if ($removeProductImageThumb) { $layout->getUpdate()->addHandle('weltpixel_quickview_removeproduct_image_thumb'); } $removeAvailability = $this->scopeConfig->getValue(self::XML_PATH_QUICKVIEW_REMOVE_AVAILABILITY, \Magento\Store\Model\ScopeInterface::SCOPE_STORE); if ($removeAvailability) { $layout->getUpdate()->addHandle('weltpixel_quickview_removeavailability'); } return $this; } }