Preference for MagentoSetup Classes not working The 2019 Stack Overflow Developer Survey Results Are InMagento2: how to add a custom import adapter?Custom module does not get its classes loadedMagento2: plugin around method not workingMagento 2 DI preference prioritymain.CRITICAL: Plugin class doesn't existfactory injection in magento 2 not workingHow to override class Virtual Type classMagento 2 not respecting preference?Magento 2 - Issue on override of Multishipping checkout modelUndo preference from third party module

What information about me do stores get via my credit card?

Why isn't the circumferential light around the M87 black hole's event horizon symmetric?

How to charge AirPods to keep battery healthy?

Why did Peik say, "I'm not an animal"?

What is this business jet?

Did Scotland spend $250,000 for the slogan "Welcome to Scotland"?

Match Roman Numerals

Why doesn't UInt have a toDouble()?

Mathematics of imaging the black hole

Does HR tell a hiring manager about salary negotiations?

Getting crown tickets for Statue of Liberty

Is it ethical to upload a automatically generated paper to a non peer-reviewed site as part of a larger research?

How to quickly solve partial fractions equation?

How to type a long/em dash `—`

Is it safe to harvest rainwater that fell on solar panels?

Can there be female White Walkers?

If climate change impact can be observed in nature, has that had any effect on rural, i.e. farming community, perception of the scientific consensus?

Is there a way to generate a uniformly distributed point on a sphere from a fixed amount of random real numbers?

Why not take a picture of a closer black hole?

What to do when moving next to a bird sanctuary with a loosely-domesticated cat?

Ubuntu Server install with full GUI

What is preventing me from simply constructing a hash that's lower than the current target?

Why can't devices on different VLANs, but on the same subnet, communicate?

Cooking pasta in a water boiler



Preference for MagentoSetup Classes not working



The 2019 Stack Overflow Developer Survey Results Are InMagento2: how to add a custom import adapter?Custom module does not get its classes loadedMagento2: plugin around method not workingMagento 2 DI preference prioritymain.CRITICAL: Plugin class doesn't existfactory injection in magento 2 not workingHow to override class Virtual Type classMagento 2 not respecting preference?Magento 2 - Issue on override of Multishipping checkout modelUndo preference from third party module



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








1















TLDR - Is there a reason I can't use preference for classes in MagentoSetup namespace, specifically during the setup:upgrade processing, OR is there something I am missing with the following preferences? They aren't being implemented.



I am trying to create a temporary module to override a couple classes under the MagentoSetup namespace. This reason behind this is because I am waiting for this PR to be deployed (https://github.com/magento/magento2/pull/18075) and in the meantime I need this functionality to work. So I'm creating a local module to implement this to avoid hacking core.



I have added two simple preferences same as I would in any other situation like this.



app/code/Company/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="MagentoSetupModelInstaller" type="CompanyModuleModelInstaller" />
<preference for="MagentoSetupValidatorDbValidator" type="CompanyModuleValidatorDbValidator" />
</config>


I have created each of those classes and added the function I want to override with a simple logging in the first line. However neither of them are taking effect. The classes/functions are being called as part of the bin/magento setup:upgrade command. Below are shortened versions of my classes.



app/code/Company/Module/Validator/DbValidator.php



<?php
declare(strict_types=1);
namespace CompanyModuleValidator;

class DbValidator extends MagentoSetupValidatorDbValidator

//...construct and props declared here...

public function checkDatabaseConnection($dbName, $dbHost, $dbUser, $dbPass = '')

$this->log->log("====Company::checkDatabaseConnection====");
//...rest of the code to implement...




app/code/Company/Module/Model/Installer.php



<?php
declare(strict_types=1);
namespace CompanyModuleModel;

class Installer extends MagentoSetupModelInstaller

//...construct and props declared here...

private function assertDbAccessible()

$this->log->log("======Company::assertDbAccessible=====");
//...




I'm wondering if they are not taking effect because perhaps I'm trying to override MagentoSetup classes during the setup:upgrade functionality. Maybe there's something in the depths of this functionality that I'm missing that would cause this not to work.



UPDATE



I just found that the MagentoSetup component is actually being registered as a "setup" component instead of a "module" (found in setup/src/Magento/Setup/registration.php). Due to this it is bootstrapped differently than modules, and as such the typical Plugin (interceptor) and Preference mechanisms will not work. So now I'm stuck trying to figure out how I can extend/modify/override any functionality from setup without modifying the core files. Is there perhaps a unique way to use dependency injection or otherwise modify this "setup" component type with Magento?










share|improve this question






























    1















    TLDR - Is there a reason I can't use preference for classes in MagentoSetup namespace, specifically during the setup:upgrade processing, OR is there something I am missing with the following preferences? They aren't being implemented.



    I am trying to create a temporary module to override a couple classes under the MagentoSetup namespace. This reason behind this is because I am waiting for this PR to be deployed (https://github.com/magento/magento2/pull/18075) and in the meantime I need this functionality to work. So I'm creating a local module to implement this to avoid hacking core.



    I have added two simple preferences same as I would in any other situation like this.



    app/code/Company/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="MagentoSetupModelInstaller" type="CompanyModuleModelInstaller" />
    <preference for="MagentoSetupValidatorDbValidator" type="CompanyModuleValidatorDbValidator" />
    </config>


    I have created each of those classes and added the function I want to override with a simple logging in the first line. However neither of them are taking effect. The classes/functions are being called as part of the bin/magento setup:upgrade command. Below are shortened versions of my classes.



    app/code/Company/Module/Validator/DbValidator.php



    <?php
    declare(strict_types=1);
    namespace CompanyModuleValidator;

    class DbValidator extends MagentoSetupValidatorDbValidator

    //...construct and props declared here...

    public function checkDatabaseConnection($dbName, $dbHost, $dbUser, $dbPass = '')

    $this->log->log("====Company::checkDatabaseConnection====");
    //...rest of the code to implement...




    app/code/Company/Module/Model/Installer.php



    <?php
    declare(strict_types=1);
    namespace CompanyModuleModel;

    class Installer extends MagentoSetupModelInstaller

    //...construct and props declared here...

    private function assertDbAccessible()

    $this->log->log("======Company::assertDbAccessible=====");
    //...




    I'm wondering if they are not taking effect because perhaps I'm trying to override MagentoSetup classes during the setup:upgrade functionality. Maybe there's something in the depths of this functionality that I'm missing that would cause this not to work.



    UPDATE



    I just found that the MagentoSetup component is actually being registered as a "setup" component instead of a "module" (found in setup/src/Magento/Setup/registration.php). Due to this it is bootstrapped differently than modules, and as such the typical Plugin (interceptor) and Preference mechanisms will not work. So now I'm stuck trying to figure out how I can extend/modify/override any functionality from setup without modifying the core files. Is there perhaps a unique way to use dependency injection or otherwise modify this "setup" component type with Magento?










    share|improve this question


























      1












      1








      1








      TLDR - Is there a reason I can't use preference for classes in MagentoSetup namespace, specifically during the setup:upgrade processing, OR is there something I am missing with the following preferences? They aren't being implemented.



      I am trying to create a temporary module to override a couple classes under the MagentoSetup namespace. This reason behind this is because I am waiting for this PR to be deployed (https://github.com/magento/magento2/pull/18075) and in the meantime I need this functionality to work. So I'm creating a local module to implement this to avoid hacking core.



      I have added two simple preferences same as I would in any other situation like this.



      app/code/Company/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="MagentoSetupModelInstaller" type="CompanyModuleModelInstaller" />
      <preference for="MagentoSetupValidatorDbValidator" type="CompanyModuleValidatorDbValidator" />
      </config>


      I have created each of those classes and added the function I want to override with a simple logging in the first line. However neither of them are taking effect. The classes/functions are being called as part of the bin/magento setup:upgrade command. Below are shortened versions of my classes.



      app/code/Company/Module/Validator/DbValidator.php



      <?php
      declare(strict_types=1);
      namespace CompanyModuleValidator;

      class DbValidator extends MagentoSetupValidatorDbValidator

      //...construct and props declared here...

      public function checkDatabaseConnection($dbName, $dbHost, $dbUser, $dbPass = '')

      $this->log->log("====Company::checkDatabaseConnection====");
      //...rest of the code to implement...




      app/code/Company/Module/Model/Installer.php



      <?php
      declare(strict_types=1);
      namespace CompanyModuleModel;

      class Installer extends MagentoSetupModelInstaller

      //...construct and props declared here...

      private function assertDbAccessible()

      $this->log->log("======Company::assertDbAccessible=====");
      //...




      I'm wondering if they are not taking effect because perhaps I'm trying to override MagentoSetup classes during the setup:upgrade functionality. Maybe there's something in the depths of this functionality that I'm missing that would cause this not to work.



      UPDATE



      I just found that the MagentoSetup component is actually being registered as a "setup" component instead of a "module" (found in setup/src/Magento/Setup/registration.php). Due to this it is bootstrapped differently than modules, and as such the typical Plugin (interceptor) and Preference mechanisms will not work. So now I'm stuck trying to figure out how I can extend/modify/override any functionality from setup without modifying the core files. Is there perhaps a unique way to use dependency injection or otherwise modify this "setup" component type with Magento?










      share|improve this question
















      TLDR - Is there a reason I can't use preference for classes in MagentoSetup namespace, specifically during the setup:upgrade processing, OR is there something I am missing with the following preferences? They aren't being implemented.



      I am trying to create a temporary module to override a couple classes under the MagentoSetup namespace. This reason behind this is because I am waiting for this PR to be deployed (https://github.com/magento/magento2/pull/18075) and in the meantime I need this functionality to work. So I'm creating a local module to implement this to avoid hacking core.



      I have added two simple preferences same as I would in any other situation like this.



      app/code/Company/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="MagentoSetupModelInstaller" type="CompanyModuleModelInstaller" />
      <preference for="MagentoSetupValidatorDbValidator" type="CompanyModuleValidatorDbValidator" />
      </config>


      I have created each of those classes and added the function I want to override with a simple logging in the first line. However neither of them are taking effect. The classes/functions are being called as part of the bin/magento setup:upgrade command. Below are shortened versions of my classes.



      app/code/Company/Module/Validator/DbValidator.php



      <?php
      declare(strict_types=1);
      namespace CompanyModuleValidator;

      class DbValidator extends MagentoSetupValidatorDbValidator

      //...construct and props declared here...

      public function checkDatabaseConnection($dbName, $dbHost, $dbUser, $dbPass = '')

      $this->log->log("====Company::checkDatabaseConnection====");
      //...rest of the code to implement...




      app/code/Company/Module/Model/Installer.php



      <?php
      declare(strict_types=1);
      namespace CompanyModuleModel;

      class Installer extends MagentoSetupModelInstaller

      //...construct and props declared here...

      private function assertDbAccessible()

      $this->log->log("======Company::assertDbAccessible=====");
      //...




      I'm wondering if they are not taking effect because perhaps I'm trying to override MagentoSetup classes during the setup:upgrade functionality. Maybe there's something in the depths of this functionality that I'm missing that would cause this not to work.



      UPDATE



      I just found that the MagentoSetup component is actually being registered as a "setup" component instead of a "module" (found in setup/src/Magento/Setup/registration.php). Due to this it is bootstrapped differently than modules, and as such the typical Plugin (interceptor) and Preference mechanisms will not work. So now I'm stuck trying to figure out how I can extend/modify/override any functionality from setup without modifying the core files. Is there perhaps a unique way to use dependency injection or otherwise modify this "setup" component type with Magento?







      magento2 magento2.3 setup-upgrade preference






      share|improve this question















      share|improve this question













      share|improve this question




      share|improve this question








      edited yesterday







      rain2o

















      asked yesterday









      rain2orain2o

      30519




      30519




















          0






          active

          oldest

          votes












          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%2f269512%2fpreference-for-magento-setup-classes-not-working%23new-answer', 'question_page');

          );

          Post as a guest















          Required, but never shown

























          0






          active

          oldest

          votes








          0






          active

          oldest

          votes









          active

          oldest

          votes






          active

          oldest

          votes















          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%2f269512%2fpreference-for-magento-setup-classes-not-working%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

          Category:9 (number) SubcategoriesMedia in category "9 (number)"Navigation menuUpload mediaGND ID: 4485639-8Library of Congress authority ID: sh85091979ReasonatorScholiaStatistics

          Circuit construction for execution of conditional statements using least significant bitHow are two different registers being used as “control”?How exactly is the stated composite state of the two registers being produced using the $R_zz$ controlled rotations?Efficiently performing controlled rotations in HHLWould this quantum algorithm implementation work?How to prepare a superposed states of odd integers from $1$ to $sqrtN$?Why is this implementation of the order finding algorithm not working?Circuit construction for Hamiltonian simulationHow can I invert the least significant bit of a certain term of a superposed state?Implementing an oracleImplementing a controlled sum operation

          Magento 2 “No Payment Methods” in Admin New OrderHow to integrate Paypal Express Checkout with the Magento APIMagento 1.5 - Sales > Order > edit order and shipping methods disappearAuto Invoice Check/Money Order Payment methodAdd more simple payment methods?Shipping methods not showingWhat should I do to change payment methods if changing the configuration has no effects?1.9 - No Payment Methods showing upMy Payment Methods not Showing for downloadable/virtual product when checkout?Magento2 API to access internal payment methodHow to call an existing payment methods in the registration form?