Skip to content

Commit

Permalink
Merge branch 'master' into TEAMS-580-add-search-route
Browse files Browse the repository at this point in the history
  • Loading branch information
AleksandrsKondratjevs authored Apr 4, 2024
2 parents 39f9cab + 3cc4a3e commit abea67f
Show file tree
Hide file tree
Showing 2 changed files with 36 additions and 1 deletion.
36 changes: 35 additions & 1 deletion src/Controller/Router.php
Original file line number Diff line number Diff line change
Expand Up @@ -49,16 +49,25 @@ 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 XML_PATH_DEMO_NOTICE_DISPLAY = 'design/head/demonotice';

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,
'demo_notice' => self::XML_PATH_DEMO_NOTICE_DISPLAY
];

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
*/
Expand Down Expand Up @@ -456,6 +465,13 @@ protected function setStoreConfigs(ActionInterface $action)
$storeConfig[$configKey] = $configValue;
}

$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);
}

Expand Down Expand Up @@ -501,6 +517,7 @@ protected function getCmsPageFromGraphqlArea(int $id = null, string $identifier
*/
protected function setNotFound(ActionInterface $action)
{
$action->setType('NOT_FOUND');
$action->setCode(404)->setPhrase('Not Found');
}

Expand Down Expand Up @@ -660,5 +677,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;
}
}

1 change: 1 addition & 0 deletions src/etc/di.xml
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@
<item name="checkout" xsi:type="string">ScandiPWA\Router\Validator\AlwaysPass</item>
<item name="compare" xsi:type="string">ScandiPWA\Router\Validator\AlwaysPass</item>
<item name="search" xsi:type="string">ScandiPWA\Router\Validator\AlwaysPass</item>
<item name="customer" xsi:type="string">ScandiPWA\Router\Validator\AlwaysPass</item>
</argument>
</arguments>
</type>
Expand Down

0 comments on commit abea67f

Please sign in to comment.