From 23e3f05151a5b88c692ff441967a3f88d23114f8 Mon Sep 17 00:00:00 2001 From: IljaFatkulin Date: Mon, 11 Mar 2024 09:24:52 +0200 Subject: [PATCH 1/4] Added tax_display_type parameter to storeConfig --- src/Controller/Router.php | 31 ++++++++++++++++++++++++++++++- 1 file changed, 30 insertions(+), 1 deletion(-) diff --git a/src/Controller/Router.php b/src/Controller/Router.php index 014ea4f..06e5237 100644 --- a/src/Controller/Router.php +++ b/src/Controller/Router.php @@ -49,16 +49,24 @@ class Router extends BaseRouter const XML_PATH_CMS_HOME_PAGE = 'web/default/cms_home_page'; const XML_PATH_THEME_USER_AGENT = 'design/theme/ua_regexp'; const XML_PATH_CATALOG_DEFAULT_SORT_BY = 'catalog/frontend/default_sort_by'; + const XML_PATH_TAX_DISPLAY_TYPE = 'tax/display/type'; const PAGE_TYPE_PRODUCT = 'PRODUCT'; const PAGE_TYPE_CATEGORY = 'CATEGORY'; const PAGE_TYPE_CMS_PAGE = 'CMS_PAGE'; + const TAX_DISPLAY_TYPE_CONFIG_KEY = 'tax_display_type'; + const CRUCIAL_STORE_CONFIG_VALUES = [ 'cms_home_page' => self::XML_PATH_CMS_HOME_PAGE, - 'catalog_default_sort_by' => self::XML_PATH_CATALOG_DEFAULT_SORT_BY + 'catalog_default_sort_by' => self::XML_PATH_CATALOG_DEFAULT_SORT_BY, + 'tax_display_type' => self::XML_PATH_TAX_DISPLAY_TYPE ]; + const DISPLAY_PRODUCT_PRICES_IN_CATALOG_INCL_TAX = 'DISPLAY_PRODUCT_PRICES_IN_CATALOG_INCL_TAX'; + const DISPLAY_PRODUCT_PRICES_IN_CATALOG_EXCL_TAX = 'DISPLAY_PRODUCT_PRICES_IN_CATALOG_EXCL_TAX'; + const DISPLAY_PRODUCT_PRICES_IN_CATALOG_BOTH = 'DISPLAY_PRODUCT_PRICES_IN_CATALOG_BOTH'; + /** * @var ValidationManagerInterface */ @@ -456,6 +464,10 @@ protected function setStoreConfigs(ActionInterface $action) $storeConfig[$configKey] = $configValue; } + if (isset($storeConfig[self::TAX_DISPLAY_TYPE_CONFIG_KEY])) { + $storeConfig[self::TAX_DISPLAY_TYPE_CONFIG_KEY] = $this->convertTaxDisplayTypeValue($storeConfig[self::TAX_DISPLAY_TYPE_CONFIG_KEY]); + } + $action->setStoreConfig($storeConfig); } @@ -660,5 +672,22 @@ protected function _checkShouldBeSecure(RequestInterface $request, $path = '') $this->_performRedirect($url); } } + + /** + * @param String $value + * @return String + */ + protected function convertTaxDisplayTypeValue($value) + { + $result = self::DISPLAY_PRODUCT_PRICES_IN_CATALOG_BOTH; + + if ($value === '1') { + $result = self::DISPLAY_PRODUCT_PRICES_IN_CATALOG_EXCL_TAX; + } elseif ($value === '2') { + $result = self::DISPLAY_PRODUCT_PRICES_IN_CATALOG_INCL_TAX; + } + + return $result; + } } From 460ac991c9ef7731eb4831a802b212e2f2cf453a Mon Sep 17 00:00:00 2001 From: IljaFatkulin Date: Mon, 11 Mar 2024 10:11:00 +0200 Subject: [PATCH 2/4] updated logic for tax_display_type --- src/Controller/Router.php | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/src/Controller/Router.php b/src/Controller/Router.php index 06e5237..dfd7c7a 100644 --- a/src/Controller/Router.php +++ b/src/Controller/Router.php @@ -60,7 +60,7 @@ class Router extends BaseRouter const CRUCIAL_STORE_CONFIG_VALUES = [ 'cms_home_page' => self::XML_PATH_CMS_HOME_PAGE, 'catalog_default_sort_by' => self::XML_PATH_CATALOG_DEFAULT_SORT_BY, - 'tax_display_type' => self::XML_PATH_TAX_DISPLAY_TYPE + // 'tax_display_type' => self::XML_PATH_TAX_DISPLAY_TYPE ]; const DISPLAY_PRODUCT_PRICES_IN_CATALOG_INCL_TAX = 'DISPLAY_PRODUCT_PRICES_IN_CATALOG_INCL_TAX'; @@ -464,9 +464,12 @@ protected function setStoreConfigs(ActionInterface $action) $storeConfig[$configKey] = $configValue; } - if (isset($storeConfig[self::TAX_DISPLAY_TYPE_CONFIG_KEY])) { - $storeConfig[self::TAX_DISPLAY_TYPE_CONFIG_KEY] = $this->convertTaxDisplayTypeValue($storeConfig[self::TAX_DISPLAY_TYPE_CONFIG_KEY]); - } + $taxDisplayConfigValue = $this->scopeConfig->getValue( + self::XML_PATH_TAX_DISPLAY_TYPE, + ScopeInterface::SCOPE_STORE, + $this->storeId + ); + $storeConfig[self::TAX_DISPLAY_TYPE_CONFIG_KEY] = $this->convertTaxDisplayTypeValue($taxDisplayConfigValue); $action->setStoreConfig($storeConfig); } From 130de1c6543f6cc617e8db3287211f89ee6b82da Mon Sep 17 00:00:00 2001 From: IljaFatkulin Date: Mon, 11 Mar 2024 10:11:45 +0200 Subject: [PATCH 3/4] remove commented code --- src/Controller/Router.php | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/src/Controller/Router.php b/src/Controller/Router.php index dfd7c7a..ea62b5a 100644 --- a/src/Controller/Router.php +++ b/src/Controller/Router.php @@ -59,8 +59,7 @@ class Router extends BaseRouter const CRUCIAL_STORE_CONFIG_VALUES = [ 'cms_home_page' => self::XML_PATH_CMS_HOME_PAGE, - 'catalog_default_sort_by' => self::XML_PATH_CATALOG_DEFAULT_SORT_BY, - // 'tax_display_type' => self::XML_PATH_TAX_DISPLAY_TYPE + 'catalog_default_sort_by' => self::XML_PATH_CATALOG_DEFAULT_SORT_BY ]; const DISPLAY_PRODUCT_PRICES_IN_CATALOG_INCL_TAX = 'DISPLAY_PRODUCT_PRICES_IN_CATALOG_INCL_TAX'; From ba3bb40f8d3fdb00e3c3e6b4de9740b8621fef67 Mon Sep 17 00:00:00 2001 From: IljaFatkulin Date: Tue, 12 Mar 2024 12:25:54 +0200 Subject: [PATCH 4/4] added demo_notice parameter to storeConfig --- src/Controller/Router.php | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/Controller/Router.php b/src/Controller/Router.php index ea62b5a..554d067 100644 --- a/src/Controller/Router.php +++ b/src/Controller/Router.php @@ -50,6 +50,7 @@ class Router extends BaseRouter const XML_PATH_THEME_USER_AGENT = 'design/theme/ua_regexp'; const XML_PATH_CATALOG_DEFAULT_SORT_BY = 'catalog/frontend/default_sort_by'; const XML_PATH_TAX_DISPLAY_TYPE = 'tax/display/type'; + const XML_PATH_DEMO_NOTICE_DISPLAY = 'design/head/demonotice'; const PAGE_TYPE_PRODUCT = 'PRODUCT'; const PAGE_TYPE_CATEGORY = 'CATEGORY'; @@ -59,7 +60,8 @@ class Router extends BaseRouter const CRUCIAL_STORE_CONFIG_VALUES = [ 'cms_home_page' => self::XML_PATH_CMS_HOME_PAGE, - 'catalog_default_sort_by' => self::XML_PATH_CATALOG_DEFAULT_SORT_BY + 'catalog_default_sort_by' => self::XML_PATH_CATALOG_DEFAULT_SORT_BY, + 'demo_notice' => self::XML_PATH_DEMO_NOTICE_DISPLAY ]; const DISPLAY_PRODUCT_PRICES_IN_CATALOG_INCL_TAX = 'DISPLAY_PRODUCT_PRICES_IN_CATALOG_INCL_TAX';