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;
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 preference
s? 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 preference
s 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
add a comment |
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 preference
s? 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 preference
s 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
add a comment |
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 preference
s? 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 preference
s 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
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 preference
s? 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 preference
s 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
magento2 magento2.3 setup-upgrade preference
edited yesterday
rain2o
asked yesterday
rain2orain2o
30519
30519
add a comment |
add a comment |
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
);
);
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
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
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.
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
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
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
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