BlockProductView.php 1.4 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950
  1. <?php
  2. namespace WeltPixel\Quickview\Plugin;
  3. class BlockProductView
  4. {
  5. const XML_PATH_QUICKVIEW_REMOVE_QTY = 'weltpixel_quickview/general/remove_qty_selector';
  6. /**
  7. * @var \Magento\Framework\App\Config\ScopeConfigInterface
  8. */
  9. protected $scopeConfig;
  10. /**
  11. *
  12. * @var \Magento\Framework\App\Request\Http
  13. */
  14. protected $request;
  15. /**
  16. * @param \Magento\Framework\App\Config\ScopeConfigInterface $scopeConfig
  17. * @param \Magento\Framework\App\Request\Http $request
  18. */
  19. public function __construct(
  20. \Magento\Framework\App\Config\ScopeConfigInterface $scopeConfig,
  21. \Magento\Framework\App\Request\Http $request)
  22. {
  23. $this->scopeConfig = $scopeConfig;
  24. $this->request = $request;
  25. }
  26. /**
  27. *
  28. * @param \Magento\Catalog\Block\Product\View $subject
  29. * @param bool $result
  30. * @return bool
  31. */
  32. public function afterShouldRenderQuantity(
  33. \Magento\Catalog\Block\Product\View $subject, $result)
  34. {
  35. if ($this->request->getFullActionName() == 'weltpixel_quickview_catalog_product_view') {
  36. $removeQtySelector = $this->scopeConfig->getValue(self::XML_PATH_QUICKVIEW_REMOVE_QTY, \Magento\Store\Model\ScopeInterface::SCOPE_STORE);
  37. return !$removeQtySelector;
  38. }
  39. return $result;
  40. }
  41. }