Guest User

Untitled

a guest
May 25th, 2018
98
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.94 KB | None | 0 0
  1. <page xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" layout="1column" xsi:noNamespaceSchemaLocation="urn:magento:framework:View/Layout/etc/page_configuration.xsd">+
  2. <body>
  3. <referenceBlock name="product_additional_data">
  4. <arguments>
  5. <argument name="view_model" xsi:type="object">CustomProductModelViewModelLocaleInfo</argument>
  6. </arguments>
  7. </referenceBlock>
  8. </body>
  9. </page>
  10.  
  11. use MagentoFrameworkViewElementBlockArgumentInterface;
  12. use MagentoFrameworkAppConfigScopeConfigInterface;
  13. use MagentoFrameworkLocaleResolver as LocaleResolver;
  14. use MagentoStoreModelScopeInterface;
  15.  
  16. class LocaleInfo implements ArgumentInterface
  17. {
  18. protected $scopeConfig;
  19. protected $localeResolver;
  20.  
  21. public function __construct(
  22. ScopeConfigInterface $scopeConfig,
  23. LocaleResolver $localeResolver
  24. ) {
  25. $this->scopeConfig = $scopeConfig;
  26. $this->localeResolver = $localeResolver;
  27. }
  28.  
  29. public function getCodes($storeId = null)
  30. {
  31. $configPath = $this->localeResolver->getDefaultLocalePath();
  32. $localeCode = $this->scopeConfig->getValue($configPath, ScopeInterface::SCOPE_STORE, $storeId);
  33.  
  34. return $localeCode;
  35. }
  36. }
  37.  
  38. $myViewModel = $block->getViewModel();
  39. echo $myViewModel->getCodes();
  40.  
  41. <block class="MagentoReviewBlockProductViewListView"
  42. name="product.info.product_additional_data"
  43. as="product_additional_data"
  44. template="Magento_Review::product/view/list.phtml"
  45. />
  46.  
  47. <page xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" layout="1column" xsi:noNamespaceSchemaLocation="urn:magento:framework:View/Layout/etc/page_configuration.xsd">+
  48. <body>
  49. <referenceBlock name="product.info.product_additional_data">
  50. <arguments>
  51. <argument name="view_model" xsi:type="object">CustomProductModelViewModelLocaleInfo</argument>
  52. </arguments>
  53. </referenceBlock>
  54. </body>
  55. </page>
Add Comment
Please, Sign In to add comment