Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <page xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" layout="1column" xsi:noNamespaceSchemaLocation="urn:magento:framework:View/Layout/etc/page_configuration.xsd">+
- <body>
- <referenceBlock name="product_additional_data">
- <arguments>
- <argument name="view_model" xsi:type="object">CustomProductModelViewModelLocaleInfo</argument>
- </arguments>
- </referenceBlock>
- </body>
- </page>
- use MagentoFrameworkViewElementBlockArgumentInterface;
- use MagentoFrameworkAppConfigScopeConfigInterface;
- use MagentoFrameworkLocaleResolver as LocaleResolver;
- use MagentoStoreModelScopeInterface;
- class LocaleInfo implements ArgumentInterface
- {
- protected $scopeConfig;
- protected $localeResolver;
- public function __construct(
- ScopeConfigInterface $scopeConfig,
- LocaleResolver $localeResolver
- ) {
- $this->scopeConfig = $scopeConfig;
- $this->localeResolver = $localeResolver;
- }
- public function getCodes($storeId = null)
- {
- $configPath = $this->localeResolver->getDefaultLocalePath();
- $localeCode = $this->scopeConfig->getValue($configPath, ScopeInterface::SCOPE_STORE, $storeId);
- return $localeCode;
- }
- }
- $myViewModel = $block->getViewModel();
- echo $myViewModel->getCodes();
- <block class="MagentoReviewBlockProductViewListView"
- name="product.info.product_additional_data"
- as="product_additional_data"
- template="Magento_Review::product/view/list.phtml"
- />
- <page xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" layout="1column" xsi:noNamespaceSchemaLocation="urn:magento:framework:View/Layout/etc/page_configuration.xsd">+
- <body>
- <referenceBlock name="product.info.product_additional_data">
- <arguments>
- <argument name="view_model" xsi:type="object">CustomProductModelViewModelLocaleInfo</argument>
- </arguments>
- </referenceBlock>
- </body>
- </page>
Add Comment
Please, Sign In to add comment