Guest User

Untitled

a guest
Dec 14th, 2017
76
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.60 KB | None | 0 0
  1. <layout xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:framework:View/Layout/etc/layout_generic.xsd">
  2. <referenceBlock name="render.product.prices">
  3. <arguments>
  4. <argument name="default" xsi:type="array">
  5. <item name="prices" xsi:type="array">
  6. <item name="final_price" xsi:type="array">
  7. <!-- item name="render_class" xsi:type="string">MagentoCatalogPricingRenderFinalPriceBox</item> -->
  8. <item name="render_template" xsi:type="string">MyVendor_MyModule::product/price/final_price.phtml</item>
  9. </item>
  10. </item>
  11. </argument>
  12. </arguments>
  13. </referenceBlock>
  14. </layout>
  15.  
  16. <type name="MagentoCatalogPricingRenderFinalPriceBox">
  17. <plugin name="MyVendor_MyModule_change_template" type="MyVendorMyModulePluginFinalPricePlugin" />
  18. </type>
  19.  
  20. <?php
  21. namespace MyVendorMyModulePlugin;
  22.  
  23. class FinalPricePlugin
  24. {
  25. public function beforeSetTemplate(MagentoCatalogPricingRenderFinalPriceBox $subject, $template)
  26. {
  27. $objectManager = MagentoFrameworkAppObjectManager::getInstance();
  28. $enable=$objectManager->create('MyVendorMyModuleHelperData')->chkIsModuleEnable();
  29. if ($enable) {
  30. if ($template == 'Magento_Catalog::product/price/final_price.phtml') {
  31. return ['MyVendor_MyModule::product/price/final_price.phtml'];
  32. }
  33. else
  34. {
  35. return [$template];
  36. }
  37. } else {
  38. return[$template];
  39. }
  40. }
  41. }
Add Comment
Please, Sign In to add comment