From 0803e7bcf05f3cd0096fbd48aed8c6ea6729c5bd Mon Sep 17 00:00:00 2001 From: klg Date: Wed, 6 Mar 2019 11:13:15 +0100 Subject: [PATCH 1/6] Create a block instead of modifying the template --- Block/AfterPrice.php | 3 +-- Model/Plugin/AfterPrice.php | 4 +-- composer.json | 4 +-- view/frontend/layout/catalog_product_view.xml | 27 +++++++++++++++++++ 4 files changed, 32 insertions(+), 6 deletions(-) create mode 100644 view/frontend/layout/catalog_product_view.xml diff --git a/Block/AfterPrice.php b/Block/AfterPrice.php index 9cfabd2..7550769 100644 --- a/Block/AfterPrice.php +++ b/Block/AfterPrice.php @@ -67,14 +67,13 @@ public function __construct( \Magento\Customer\Model\Session $session, array $data = [] ){ - parent::__construct($context, $data); - $this->_scopeConfig = $context->getScopeConfig(); $this->_registry = $registry; $this->_taxCalculation = $taxCalculation; $this->_session = $session; $this->_storeManager = $context->getStoreManager(); $this->_urlBuilder = $context->getUrlBuilder(); + parent::__construct($context, $data); } /** diff --git a/Model/Plugin/AfterPrice.php b/Model/Plugin/AfterPrice.php index 5a746c2..56f0cdd 100644 --- a/Model/Plugin/AfterPrice.php +++ b/Model/Plugin/AfterPrice.php @@ -78,7 +78,7 @@ public function aroundRender(Render $subject, \Closure $closure, ...$params) // run default render first $renderHtml = $closure(...$params); - try{ + /*try{ // Get Price Code and Product list($priceCode, $productInterceptor) = $params; $emptyTierPrices = empty($productInterceptor->getTierPrice()); @@ -91,7 +91,7 @@ public function aroundRender(Render $subject, \Closure $closure, ...$params) } catch (\Exception $ex) { // if an error occurs, just render the default since it is preallocated return $renderHtml; - } + }*/ return $renderHtml; } diff --git a/composer.json b/composer.json index a938579..34eab0e 100644 --- a/composer.json +++ b/composer.json @@ -2,7 +2,7 @@ "name": "magenerds/germanlaw", "description": "This module provides general settings for german stores", "require": { - "magento/framework": "^100.0.0|^101.0.0|^102.0.0", + "magento/framework": "^100.0.0|^101.0.0", "magenerds/dashboard": "^1.0" }, "repositories": { @@ -21,4 +21,4 @@ "Magenerds\\GermanLaw\\": "" } } -} +} \ No newline at end of file diff --git a/view/frontend/layout/catalog_product_view.xml b/view/frontend/layout/catalog_product_view.xml new file mode 100644 index 0000000..24f1ae2 --- /dev/null +++ b/view/frontend/layout/catalog_product_view.xml @@ -0,0 +1,27 @@ + + + + + + + + + From 2869a2f7ab0bdc83b044d986043d8ef041156904 Mon Sep 17 00:00:00 2001 From: klg Date: Wed, 6 Mar 2019 11:16:08 +0100 Subject: [PATCH 2/6] Rebase --- Block/AfterPrice.php | 3 ++- composer.json | 2 +- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/Block/AfterPrice.php b/Block/AfterPrice.php index 7550769..9cfabd2 100644 --- a/Block/AfterPrice.php +++ b/Block/AfterPrice.php @@ -67,13 +67,14 @@ public function __construct( \Magento\Customer\Model\Session $session, array $data = [] ){ + parent::__construct($context, $data); + $this->_scopeConfig = $context->getScopeConfig(); $this->_registry = $registry; $this->_taxCalculation = $taxCalculation; $this->_session = $session; $this->_storeManager = $context->getStoreManager(); $this->_urlBuilder = $context->getUrlBuilder(); - parent::__construct($context, $data); } /** diff --git a/composer.json b/composer.json index 34eab0e..379a631 100644 --- a/composer.json +++ b/composer.json @@ -2,7 +2,7 @@ "name": "magenerds/germanlaw", "description": "This module provides general settings for german stores", "require": { - "magento/framework": "^100.0.0|^101.0.0", + "magento/framework": "^100.0.0|^101.0.0|^102.0.0", "magenerds/dashboard": "^1.0" }, "repositories": { From 5ed6687500800b1e8de9f39581e079d8887bac5e Mon Sep 17 00:00:00 2001 From: klg Date: Wed, 6 Mar 2019 11:17:43 +0100 Subject: [PATCH 3/6] Remove unneeded classes --- Model/Plugin/AfterPrice.php | 114 ------------------------------------ etc/di.xml | 24 -------- 2 files changed, 138 deletions(-) delete mode 100644 Model/Plugin/AfterPrice.php delete mode 100644 etc/di.xml diff --git a/Model/Plugin/AfterPrice.php b/Model/Plugin/AfterPrice.php deleted file mode 100644 index 56f0cdd..0000000 --- a/Model/Plugin/AfterPrice.php +++ /dev/null @@ -1,114 +0,0 @@ - - */ -namespace Magenerds\GermanLaw\Model\Plugin; - -use Magento\Framework\Pricing\Render; -use Magento\Framework\Pricing\SaleableInterface; - -/** - * Class AfterPrice - * @package Magenerds\GermanLaw\Model\Plugin - */ -class AfterPrice -{ - /** - * Hold final price code - * - * @var string - */ - const FINAL_PRICE = 'final_price'; - - /** - * Hold tier price code - * - * @var string - */ - const TIER_PRICE = 'tier_price'; - - /** - * Hold layout - * - * @var \Magento\Framework\View\LayoutInterface - */ - protected $_layout; - - /** - * Hold after price html string - * - * @var null|string - */ - protected $_afterPriceHtml = null; - - /** - * Constructor - * - * @param \Magento\Framework\View\LayoutInterface $layout - */ - public function __construct( - \Magento\Framework\View\LayoutInterface $layout - ){ - $this->_layout = $layout; - } - - /** - * Plugin for price rendering in order to display after price information - * - * @param \Magento\Framework\Pricing\Render $subject - * @oaram \Closure $closure - * @param array $params - * @return string - */ - public function aroundRender(Render $subject, \Closure $closure, ...$params) - { - // run default render first - $renderHtml = $closure(...$params); - - /*try{ - // Get Price Code and Product - list($priceCode, $productInterceptor) = $params; - $emptyTierPrices = empty($productInterceptor->getTierPrice()); - - // If it is final price block and no tier prices exist set additional render - // If it is tier price block and tier prices exist set additional render - if ((static::FINAL_PRICE === $priceCode && $emptyTierPrices) || (static::TIER_PRICE === $priceCode && !$emptyTierPrices)) { - $renderHtml .= $this->_getAfterPriceHtml(); - } - } catch (\Exception $ex) { - // if an error occurs, just render the default since it is preallocated - return $renderHtml; - }*/ - - return $renderHtml; - } - - /** - * Renders and caches the after price html - * - * @return null|string - */ - protected function _getAfterPriceHtml() - { - if (null === $this->_afterPriceHtml) { - $afterPriceBlock = $this->_layout->createBlock('Magenerds\GermanLaw\Block\AfterPrice', 'after_price'); - $afterPriceBlock->setTemplate('Magenerds_GermanLaw::price/after.phtml'); - $this->_afterPriceHtml = $afterPriceBlock->toHtml(); - } - - return $this->_afterPriceHtml; - } -} diff --git a/etc/di.xml b/etc/di.xml deleted file mode 100644 index ba40742..0000000 --- a/etc/di.xml +++ /dev/null @@ -1,24 +0,0 @@ - - - - - - - From f1c5efadb11a155ed7ee3fad6e51423135a8a327 Mon Sep 17 00:00:00 2001 From: klg Date: Wed, 6 Mar 2019 11:18:11 +0100 Subject: [PATCH 4/6] Copyright --- view/frontend/layout/catalog_product_view.xml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/view/frontend/layout/catalog_product_view.xml b/view/frontend/layout/catalog_product_view.xml index 24f1ae2..4907862 100644 --- a/view/frontend/layout/catalog_product_view.xml +++ b/view/frontend/layout/catalog_product_view.xml @@ -12,8 +12,8 @@ * @category Magenerds * @package Magenerds_GermanLaw * @subpackage view - * @author Florian Sydekum - * @copyright Copyright (c) 2016 TechDivision GmbH (http://www.techdivision.com) + * @author Konrad Langenberg + * @copyright Copyright (c) 2019 TechDivision GmbH (http://www.techdivision.com) * @link http://www.techdivision.com/ */ --> From b5db0dcef088cda94a2261f0ae583cad838f3895 Mon Sep 17 00:00:00 2001 From: klg Date: Wed, 6 Mar 2019 11:25:02 +0100 Subject: [PATCH 5/6] Updated container name --- view/frontend/layout/catalog_product_view.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/view/frontend/layout/catalog_product_view.xml b/view/frontend/layout/catalog_product_view.xml index 4907862..0d0f22c 100644 --- a/view/frontend/layout/catalog_product_view.xml +++ b/view/frontend/layout/catalog_product_view.xml @@ -20,7 +20,7 @@ - From caf4370f4a93db226d0973e38f02a2fe22377d95 Mon Sep 17 00:00:00 2001 From: klg Date: Wed, 6 Mar 2019 15:11:37 +0100 Subject: [PATCH 6/6] Add new line to composer.json --- composer.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/composer.json b/composer.json index 379a631..a938579 100644 --- a/composer.json +++ b/composer.json @@ -21,4 +21,4 @@ "Magenerds\\GermanLaw\\": "" } } -} \ No newline at end of file +}