Override method in LayoutProcessor The 2019 Stack Overflow Developer Survey Results Are InMagento2 rewrite _prepareCollection method in wishlist returning blank pagemain.CRITICAL: Plugin class doesn't existModel Override issue in magento 2Overridden Cart block does not load templateMagento 2.2.0 - checkout_index_index.xml shippingAdditional not workingMagento 2.2.1: Add Custom Upload file attribute in CheckoutMagento offline custom Payment method with drop down listMagento 2.2.5: Overriding Admin Controller sales/orderOverwrite private method in LayoutProcessor?Magento 2.2.5: Add, Update and Delete existing products Custom Options

Why Did Howard Stark Use All The Vibranium They Had On A Prototype Shield?

I looked up a future colleague on LinkedIn before I started a job. I told my colleague about it and he seemed surprised. Should I apologize?

CiviEvent: Public link for events of a specific type

How can I create a character who can assume the widest possible range of creature sizes?

Why do UK politicians seemingly ignore opinion polls on Brexit?

Landlord wants to switch my lease to a "Land contract" to "get back at the city"

A poker game description that does not feel gimmicky

Dual Citizen. Exited the US on Italian passport recently

Monty Hall variation

Could JWST stay at L2 "forever"?

Lethal sonic weapons

What are the motivations for publishing new editions of an existing textbook, beyond new discoveries in a field?

What is the purpose of the constant in the probability density function

Pristine Bit Checking

Does duplicating a spell with Wish count as casting that spell?

Patience, young "Padovan"

Are there any other methods to apply to solving simultaneous equations?

If a poisoned arrow's piercing damage is reduced to 0, do you still get poisoned?

Why don't Unix/Linux systems traverse through directories until they find the required version of a linked library?

Limit the amount of RAM Mathematica may access?

How to answer pointed "are you quitting" questioning when I don't want them to suspect

What could be the right powersource for 15 seconds lifespan disposable giant chainsaw?

What does "rabbited" mean/imply in this sentence?

Inflated grade on resume at previous job, might former employer tell new employer?



Override method in LayoutProcessor



The 2019 Stack Overflow Developer Survey Results Are InMagento2 rewrite _prepareCollection method in wishlist returning blank pagemain.CRITICAL: Plugin class doesn't existModel Override issue in magento 2Overridden Cart block does not load templateMagento 2.2.0 - checkout_index_index.xml shippingAdditional not workingMagento 2.2.1: Add Custom Upload file attribute in CheckoutMagento offline custom Payment method with drop down listMagento 2.2.5: Overriding Admin Controller sales/orderOverwrite private method in LayoutProcessor?Magento 2.2.5: Add, Update and Delete existing products Custom Options



.everyoneloves__top-leaderboard:empty,.everyoneloves__mid-leaderboard:empty,.everyoneloves__bot-mid-leaderboard:empty margin-bottom:0;








3















I want to make changes(PHP code) to the method processPaymentConfiguration, but I don't know how I can override the method so my changes have a higher priority. I can alter the LayoutProcessor file but it's never good to apply changes to a core file.



So my question; is this possible and what do I need to do to achieve this?



Vendor/Module/Block/Checkout/LayoutProcessor.php



<?php
namespace VendorModuleBlockCheckout;

use MagentoFrameworkAppObjectManager;
use MagentoCheckoutBlockCheckoutLayoutProcessorInterface;
use MagentoCustomerModelAttributeMetadataDataProvider;
use MagentoUiComponentFormAttributeMapper;
use MagentoCheckoutBlockCheckoutAttributeMerger;
use MagentoCustomerModelOptions;

class LayoutProcessor implements LayoutProcessorInterface

private $attributeMetadataDataProvider;
protected $attributeMapper;
protected $merger;
private $options;

public function __construct(
AttributeMetadataDataProvider $attributeMetadataDataProvider,
AttributeMapper $attributeMapper,
AttributeMerger $merger
)
$this->attributeMetadataDataProvider = $attributeMetadataDataProvider;
$this->attributeMapper = $attributeMapper;
$this->merger = $merger;


private function getOptions()

//same code as Magento/Checkout/Block/LayoutProcessor::getOptions()



private function getAddressAttributes()

//same code as Magento/Checkout/Block/LayoutProcessor::getAddressAttributes()


private function convertElementsToSelect($elements, $attributesToConvert)

//same code as Magento/Checkout/Block/LayoutProcessor::convertElementsToSelect()


public function process($jsLayout)

//same code as Magento/Checkout/Block/LayoutProcessor::process()


private function processPaymentConfiguration(array &$configuration, array $elements)

/*
code from Magento/Checkout/Block/LayoutProcessor::processPaymentConfiguration()
with a couple changes.
It works when I apply the changes in code file (vendor/magento/magento-checkout/...)
*/




When I var_dump processPaymentConfigurationfrom the core and my custom code, I get the same results. So it looks like the code executes and returns the right thing but nothing is happening.



Vendor/Module/etc/di.xml



<?xml version="1.0"?>
<config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:noNamespaceSchemaLocation="urn:magento:framework:ObjectManager/etc/config.xsd">
<preference for="MagentoCheckoutBlockCheckoutLayoutProcessor" type="VendorModuleBlockCheckoutLayoutProcessor" />
</config>









share|improve this question



















  • 1





    Simply override the block. You can achieve this with help of plugin also.

    – Dinesh Yadav
    Jun 7 '17 at 12:19











  • processPaymentConfiguration is private method. So you don't modify even if you overwrite LayoutProcessor class. Create a plugin for LayoutProcessor::process, then you need to modify layout payment config array.

    – Sohel Rana
    Jun 7 '17 at 15:21











  • @SohelRana Why should I modify an array, this doesn't allow me to change a method. Am I missing something?

    – creativename
    Jun 8 '17 at 7:42











  • @DineshYadav I overrided the block, turns out I forgot to update my di.xml, but it still does not work. I've updated my question with my code.

    – creativename
    Jun 9 '17 at 9:26

















3















I want to make changes(PHP code) to the method processPaymentConfiguration, but I don't know how I can override the method so my changes have a higher priority. I can alter the LayoutProcessor file but it's never good to apply changes to a core file.



So my question; is this possible and what do I need to do to achieve this?



Vendor/Module/Block/Checkout/LayoutProcessor.php



<?php
namespace VendorModuleBlockCheckout;

use MagentoFrameworkAppObjectManager;
use MagentoCheckoutBlockCheckoutLayoutProcessorInterface;
use MagentoCustomerModelAttributeMetadataDataProvider;
use MagentoUiComponentFormAttributeMapper;
use MagentoCheckoutBlockCheckoutAttributeMerger;
use MagentoCustomerModelOptions;

class LayoutProcessor implements LayoutProcessorInterface

private $attributeMetadataDataProvider;
protected $attributeMapper;
protected $merger;
private $options;

public function __construct(
AttributeMetadataDataProvider $attributeMetadataDataProvider,
AttributeMapper $attributeMapper,
AttributeMerger $merger
)
$this->attributeMetadataDataProvider = $attributeMetadataDataProvider;
$this->attributeMapper = $attributeMapper;
$this->merger = $merger;


private function getOptions()

//same code as Magento/Checkout/Block/LayoutProcessor::getOptions()



private function getAddressAttributes()

//same code as Magento/Checkout/Block/LayoutProcessor::getAddressAttributes()


private function convertElementsToSelect($elements, $attributesToConvert)

//same code as Magento/Checkout/Block/LayoutProcessor::convertElementsToSelect()


public function process($jsLayout)

//same code as Magento/Checkout/Block/LayoutProcessor::process()


private function processPaymentConfiguration(array &$configuration, array $elements)

/*
code from Magento/Checkout/Block/LayoutProcessor::processPaymentConfiguration()
with a couple changes.
It works when I apply the changes in code file (vendor/magento/magento-checkout/...)
*/




When I var_dump processPaymentConfigurationfrom the core and my custom code, I get the same results. So it looks like the code executes and returns the right thing but nothing is happening.



Vendor/Module/etc/di.xml



<?xml version="1.0"?>
<config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:noNamespaceSchemaLocation="urn:magento:framework:ObjectManager/etc/config.xsd">
<preference for="MagentoCheckoutBlockCheckoutLayoutProcessor" type="VendorModuleBlockCheckoutLayoutProcessor" />
</config>









share|improve this question



















  • 1





    Simply override the block. You can achieve this with help of plugin also.

    – Dinesh Yadav
    Jun 7 '17 at 12:19











  • processPaymentConfiguration is private method. So you don't modify even if you overwrite LayoutProcessor class. Create a plugin for LayoutProcessor::process, then you need to modify layout payment config array.

    – Sohel Rana
    Jun 7 '17 at 15:21











  • @SohelRana Why should I modify an array, this doesn't allow me to change a method. Am I missing something?

    – creativename
    Jun 8 '17 at 7:42











  • @DineshYadav I overrided the block, turns out I forgot to update my di.xml, but it still does not work. I've updated my question with my code.

    – creativename
    Jun 9 '17 at 9:26













3












3








3


1






I want to make changes(PHP code) to the method processPaymentConfiguration, but I don't know how I can override the method so my changes have a higher priority. I can alter the LayoutProcessor file but it's never good to apply changes to a core file.



So my question; is this possible and what do I need to do to achieve this?



Vendor/Module/Block/Checkout/LayoutProcessor.php



<?php
namespace VendorModuleBlockCheckout;

use MagentoFrameworkAppObjectManager;
use MagentoCheckoutBlockCheckoutLayoutProcessorInterface;
use MagentoCustomerModelAttributeMetadataDataProvider;
use MagentoUiComponentFormAttributeMapper;
use MagentoCheckoutBlockCheckoutAttributeMerger;
use MagentoCustomerModelOptions;

class LayoutProcessor implements LayoutProcessorInterface

private $attributeMetadataDataProvider;
protected $attributeMapper;
protected $merger;
private $options;

public function __construct(
AttributeMetadataDataProvider $attributeMetadataDataProvider,
AttributeMapper $attributeMapper,
AttributeMerger $merger
)
$this->attributeMetadataDataProvider = $attributeMetadataDataProvider;
$this->attributeMapper = $attributeMapper;
$this->merger = $merger;


private function getOptions()

//same code as Magento/Checkout/Block/LayoutProcessor::getOptions()



private function getAddressAttributes()

//same code as Magento/Checkout/Block/LayoutProcessor::getAddressAttributes()


private function convertElementsToSelect($elements, $attributesToConvert)

//same code as Magento/Checkout/Block/LayoutProcessor::convertElementsToSelect()


public function process($jsLayout)

//same code as Magento/Checkout/Block/LayoutProcessor::process()


private function processPaymentConfiguration(array &$configuration, array $elements)

/*
code from Magento/Checkout/Block/LayoutProcessor::processPaymentConfiguration()
with a couple changes.
It works when I apply the changes in code file (vendor/magento/magento-checkout/...)
*/




When I var_dump processPaymentConfigurationfrom the core and my custom code, I get the same results. So it looks like the code executes and returns the right thing but nothing is happening.



Vendor/Module/etc/di.xml



<?xml version="1.0"?>
<config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:noNamespaceSchemaLocation="urn:magento:framework:ObjectManager/etc/config.xsd">
<preference for="MagentoCheckoutBlockCheckoutLayoutProcessor" type="VendorModuleBlockCheckoutLayoutProcessor" />
</config>









share|improve this question
















I want to make changes(PHP code) to the method processPaymentConfiguration, but I don't know how I can override the method so my changes have a higher priority. I can alter the LayoutProcessor file but it's never good to apply changes to a core file.



So my question; is this possible and what do I need to do to achieve this?



Vendor/Module/Block/Checkout/LayoutProcessor.php



<?php
namespace VendorModuleBlockCheckout;

use MagentoFrameworkAppObjectManager;
use MagentoCheckoutBlockCheckoutLayoutProcessorInterface;
use MagentoCustomerModelAttributeMetadataDataProvider;
use MagentoUiComponentFormAttributeMapper;
use MagentoCheckoutBlockCheckoutAttributeMerger;
use MagentoCustomerModelOptions;

class LayoutProcessor implements LayoutProcessorInterface

private $attributeMetadataDataProvider;
protected $attributeMapper;
protected $merger;
private $options;

public function __construct(
AttributeMetadataDataProvider $attributeMetadataDataProvider,
AttributeMapper $attributeMapper,
AttributeMerger $merger
)
$this->attributeMetadataDataProvider = $attributeMetadataDataProvider;
$this->attributeMapper = $attributeMapper;
$this->merger = $merger;


private function getOptions()

//same code as Magento/Checkout/Block/LayoutProcessor::getOptions()



private function getAddressAttributes()

//same code as Magento/Checkout/Block/LayoutProcessor::getAddressAttributes()


private function convertElementsToSelect($elements, $attributesToConvert)

//same code as Magento/Checkout/Block/LayoutProcessor::convertElementsToSelect()


public function process($jsLayout)

//same code as Magento/Checkout/Block/LayoutProcessor::process()


private function processPaymentConfiguration(array &$configuration, array $elements)

/*
code from Magento/Checkout/Block/LayoutProcessor::processPaymentConfiguration()
with a couple changes.
It works when I apply the changes in code file (vendor/magento/magento-checkout/...)
*/




When I var_dump processPaymentConfigurationfrom the core and my custom code, I get the same results. So it looks like the code executes and returns the right thing but nothing is happening.



Vendor/Module/etc/di.xml



<?xml version="1.0"?>
<config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:noNamespaceSchemaLocation="urn:magento:framework:ObjectManager/etc/config.xsd">
<preference for="MagentoCheckoutBlockCheckoutLayoutProcessor" type="VendorModuleBlockCheckoutLayoutProcessor" />
</config>






magento2 checkout overrides payment-methods






share|improve this question















share|improve this question













share|improve this question




share|improve this question








edited Jun 9 '17 at 8:26







creativename

















asked Jun 7 '17 at 12:09









creativenamecreativename

328




328







  • 1





    Simply override the block. You can achieve this with help of plugin also.

    – Dinesh Yadav
    Jun 7 '17 at 12:19











  • processPaymentConfiguration is private method. So you don't modify even if you overwrite LayoutProcessor class. Create a plugin for LayoutProcessor::process, then you need to modify layout payment config array.

    – Sohel Rana
    Jun 7 '17 at 15:21











  • @SohelRana Why should I modify an array, this doesn't allow me to change a method. Am I missing something?

    – creativename
    Jun 8 '17 at 7:42











  • @DineshYadav I overrided the block, turns out I forgot to update my di.xml, but it still does not work. I've updated my question with my code.

    – creativename
    Jun 9 '17 at 9:26












  • 1





    Simply override the block. You can achieve this with help of plugin also.

    – Dinesh Yadav
    Jun 7 '17 at 12:19











  • processPaymentConfiguration is private method. So you don't modify even if you overwrite LayoutProcessor class. Create a plugin for LayoutProcessor::process, then you need to modify layout payment config array.

    – Sohel Rana
    Jun 7 '17 at 15:21











  • @SohelRana Why should I modify an array, this doesn't allow me to change a method. Am I missing something?

    – creativename
    Jun 8 '17 at 7:42











  • @DineshYadav I overrided the block, turns out I forgot to update my di.xml, but it still does not work. I've updated my question with my code.

    – creativename
    Jun 9 '17 at 9:26







1




1





Simply override the block. You can achieve this with help of plugin also.

– Dinesh Yadav
Jun 7 '17 at 12:19





Simply override the block. You can achieve this with help of plugin also.

– Dinesh Yadav
Jun 7 '17 at 12:19













processPaymentConfiguration is private method. So you don't modify even if you overwrite LayoutProcessor class. Create a plugin for LayoutProcessor::process, then you need to modify layout payment config array.

– Sohel Rana
Jun 7 '17 at 15:21





processPaymentConfiguration is private method. So you don't modify even if you overwrite LayoutProcessor class. Create a plugin for LayoutProcessor::process, then you need to modify layout payment config array.

– Sohel Rana
Jun 7 '17 at 15:21













@SohelRana Why should I modify an array, this doesn't allow me to change a method. Am I missing something?

– creativename
Jun 8 '17 at 7:42





@SohelRana Why should I modify an array, this doesn't allow me to change a method. Am I missing something?

– creativename
Jun 8 '17 at 7:42













@DineshYadav I overrided the block, turns out I forgot to update my di.xml, but it still does not work. I've updated my question with my code.

– creativename
Jun 9 '17 at 9:26





@DineshYadav I overrided the block, turns out I forgot to update my di.xml, but it still does not work. I've updated my question with my code.

– creativename
Jun 9 '17 at 9:26










2 Answers
2






active

oldest

votes


















0














you have to "extend" the class not "implement" interface..



class LayoutProcessor extends MagentoCheckoutBlockCheckoutLayoutProcessor





share|improve this answer






























    0














    1. Create your own module if you do not have created it yet.

    2. Implement MagentoCheckoutBlockCheckoutLayoutProcessorInterface::process in your module through YourModule/etc/frontend/di.xml.
      Check implementation in MagentoCheckoutBlockCheckoutLayoutProcessor::process as a reference



    3. In your new implementation of LayoutProcessorInterface::process method get all payment methods by



      $paymentList = $jsLayout['components']['checkout']['children']['steps']['children']['billing-step']['children']['payment']['children']['payments-list']['children'] ?? null;



    4. Iterate through this payment list and modify layout configuration as needed.


    5. Return modified $jsLayout from your implementation of LayoutProcessorInterface::process method.





    share























      Your Answer








      StackExchange.ready(function()
      var channelOptions =
      tags: "".split(" "),
      id: "479"
      ;
      initTagRenderer("".split(" "), "".split(" "), channelOptions);

      StackExchange.using("externalEditor", function()
      // Have to fire editor after snippets, if snippets enabled
      if (StackExchange.settings.snippets.snippetsEnabled)
      StackExchange.using("snippets", function()
      createEditor();
      );

      else
      createEditor();

      );

      function createEditor()
      StackExchange.prepareEditor(
      heartbeatType: 'answer',
      autoActivateHeartbeat: false,
      convertImagesToLinks: false,
      noModals: true,
      showLowRepImageUploadWarning: true,
      reputationToPostImages: null,
      bindNavPrevention: true,
      postfix: "",
      imageUploader:
      brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
      contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
      allowUrls: true
      ,
      onDemand: true,
      discardSelector: ".discard-answer"
      ,immediatelyShowMarkdownHelp:true
      );



      );













      draft saved

      draft discarded


















      StackExchange.ready(
      function ()
      StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fmagento.stackexchange.com%2fquestions%2f177893%2foverride-method-in-layoutprocessor%23new-answer', 'question_page');

      );

      Post as a guest















      Required, but never shown

























      2 Answers
      2






      active

      oldest

      votes








      2 Answers
      2






      active

      oldest

      votes









      active

      oldest

      votes






      active

      oldest

      votes









      0














      you have to "extend" the class not "implement" interface..



      class LayoutProcessor extends MagentoCheckoutBlockCheckoutLayoutProcessor





      share|improve this answer



























        0














        you have to "extend" the class not "implement" interface..



        class LayoutProcessor extends MagentoCheckoutBlockCheckoutLayoutProcessor





        share|improve this answer

























          0












          0








          0







          you have to "extend" the class not "implement" interface..



          class LayoutProcessor extends MagentoCheckoutBlockCheckoutLayoutProcessor





          share|improve this answer













          you have to "extend" the class not "implement" interface..



          class LayoutProcessor extends MagentoCheckoutBlockCheckoutLayoutProcessor






          share|improve this answer












          share|improve this answer



          share|improve this answer










          answered Dec 13 '17 at 10:12









          Naveed AsimNaveed Asim

          2,7442317




          2,7442317























              0














              1. Create your own module if you do not have created it yet.

              2. Implement MagentoCheckoutBlockCheckoutLayoutProcessorInterface::process in your module through YourModule/etc/frontend/di.xml.
                Check implementation in MagentoCheckoutBlockCheckoutLayoutProcessor::process as a reference



              3. In your new implementation of LayoutProcessorInterface::process method get all payment methods by



                $paymentList = $jsLayout['components']['checkout']['children']['steps']['children']['billing-step']['children']['payment']['children']['payments-list']['children'] ?? null;



              4. Iterate through this payment list and modify layout configuration as needed.


              5. Return modified $jsLayout from your implementation of LayoutProcessorInterface::process method.





              share



























                0














                1. Create your own module if you do not have created it yet.

                2. Implement MagentoCheckoutBlockCheckoutLayoutProcessorInterface::process in your module through YourModule/etc/frontend/di.xml.
                  Check implementation in MagentoCheckoutBlockCheckoutLayoutProcessor::process as a reference



                3. In your new implementation of LayoutProcessorInterface::process method get all payment methods by



                  $paymentList = $jsLayout['components']['checkout']['children']['steps']['children']['billing-step']['children']['payment']['children']['payments-list']['children'] ?? null;



                4. Iterate through this payment list and modify layout configuration as needed.


                5. Return modified $jsLayout from your implementation of LayoutProcessorInterface::process method.





                share

























                  0












                  0








                  0







                  1. Create your own module if you do not have created it yet.

                  2. Implement MagentoCheckoutBlockCheckoutLayoutProcessorInterface::process in your module through YourModule/etc/frontend/di.xml.
                    Check implementation in MagentoCheckoutBlockCheckoutLayoutProcessor::process as a reference



                  3. In your new implementation of LayoutProcessorInterface::process method get all payment methods by



                    $paymentList = $jsLayout['components']['checkout']['children']['steps']['children']['billing-step']['children']['payment']['children']['payments-list']['children'] ?? null;



                  4. Iterate through this payment list and modify layout configuration as needed.


                  5. Return modified $jsLayout from your implementation of LayoutProcessorInterface::process method.





                  share













                  1. Create your own module if you do not have created it yet.

                  2. Implement MagentoCheckoutBlockCheckoutLayoutProcessorInterface::process in your module through YourModule/etc/frontend/di.xml.
                    Check implementation in MagentoCheckoutBlockCheckoutLayoutProcessor::process as a reference



                  3. In your new implementation of LayoutProcessorInterface::process method get all payment methods by



                    $paymentList = $jsLayout['components']['checkout']['children']['steps']['children']['billing-step']['children']['payment']['children']['payments-list']['children'] ?? null;



                  4. Iterate through this payment list and modify layout configuration as needed.


                  5. Return modified $jsLayout from your implementation of LayoutProcessorInterface::process method.






                  share











                  share


                  share










                  answered 8 mins ago









                  transversustransversus

                  212




                  212



























                      draft saved

                      draft discarded
















































                      Thanks for contributing an answer to Magento Stack Exchange!


                      • Please be sure to answer the question. Provide details and share your research!

                      But avoid


                      • Asking for help, clarification, or responding to other answers.

                      • Making statements based on opinion; back them up with references or personal experience.

                      To learn more, see our tips on writing great answers.




                      draft saved


                      draft discarded














                      StackExchange.ready(
                      function ()
                      StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fmagento.stackexchange.com%2fquestions%2f177893%2foverride-method-in-layoutprocessor%23new-answer', 'question_page');

                      );

                      Post as a guest















                      Required, but never shown





















































                      Required, but never shown














                      Required, but never shown












                      Required, but never shown







                      Required, but never shown

































                      Required, but never shown














                      Required, but never shown












                      Required, but never shown







                      Required, but never shown







                      Popular posts from this blog

                      Nidaros erkebispedøme

                      Birsay

                      Where did Arya get these scars? Unicorn Meta Zoo #1: Why another podcast? Announcing the arrival of Valued Associate #679: Cesar Manara Favourite questions and answers from the 1st quarter of 2019Why did Arya refuse to end it?Has the pronunciation of Arya Stark's name changed?Has Arya forgiven people?Why did Arya Stark lose her vision?Why can Arya still use the faces?Has the Narrow Sea become narrower?Does Arya Stark know how to make poisons outside of the House of Black and White?Why did Nymeria leave Arya?Why did Arya not kill the Lannister soldiers she encountered in the Riverlands?What is the current canonical age of Sansa, Bran and Arya Stark?