Magento 2 - How to use plugin to change product visiblity after saving product from backend?
Clash Royale CLAN TAG#URR8PPP
.everyoneloves__top-leaderboard:empty,.everyoneloves__mid-leaderboard:empty margin-bottom:0;
up vote
2
down vote
favorite
I am new in Magento 2 and I want to change product visibility after saving product from backend using plugin.
For this I have created custom module and plugin, but I am not sure that we can achieve this using of plugin or not? Or Should I go with Observer?
I am trying something like : -
app/code/Custom/HelloWorld/etc/di.xml
<type name="MagentoCatalogModelProduct">
<plugin name="Custom-HelloWorld-product-model" type="CustomHelloWorldPluginProductPlugin" sortOrder="1" />
</type>
app/code/Custom/HelloWorld/Plugin/ProductPlugin.php
namespace CustomHelloWorldPlugin;
class ProductPlugin
public function beforeSetVisiblity(MagentoCatalogModelProduct $subject, $visiblity)
....
Please suggest. Thanks!
magento2 admin upgrade visibility
add a comment |Â
up vote
2
down vote
favorite
I am new in Magento 2 and I want to change product visibility after saving product from backend using plugin.
For this I have created custom module and plugin, but I am not sure that we can achieve this using of plugin or not? Or Should I go with Observer?
I am trying something like : -
app/code/Custom/HelloWorld/etc/di.xml
<type name="MagentoCatalogModelProduct">
<plugin name="Custom-HelloWorld-product-model" type="CustomHelloWorldPluginProductPlugin" sortOrder="1" />
</type>
app/code/Custom/HelloWorld/Plugin/ProductPlugin.php
namespace CustomHelloWorldPlugin;
class ProductPlugin
public function beforeSetVisiblity(MagentoCatalogModelProduct $subject, $visiblity)
....
Please suggest. Thanks!
magento2 admin upgrade visibility
yes, you can go with plugin.
â kunj
Aug 30 at 6:54
1
Thanks for your suggestion. I also have to update DB value as well. Can you please give me any doc links so I can get more information and implement this in our module.
â Mr. Nanhe
Aug 30 at 7:10
Sure, you can learn more from here : mageplaza.com/magento-2-module-development/â¦
â kunj
Aug 30 at 7:10
add a comment |Â
up vote
2
down vote
favorite
up vote
2
down vote
favorite
I am new in Magento 2 and I want to change product visibility after saving product from backend using plugin.
For this I have created custom module and plugin, but I am not sure that we can achieve this using of plugin or not? Or Should I go with Observer?
I am trying something like : -
app/code/Custom/HelloWorld/etc/di.xml
<type name="MagentoCatalogModelProduct">
<plugin name="Custom-HelloWorld-product-model" type="CustomHelloWorldPluginProductPlugin" sortOrder="1" />
</type>
app/code/Custom/HelloWorld/Plugin/ProductPlugin.php
namespace CustomHelloWorldPlugin;
class ProductPlugin
public function beforeSetVisiblity(MagentoCatalogModelProduct $subject, $visiblity)
....
Please suggest. Thanks!
magento2 admin upgrade visibility
I am new in Magento 2 and I want to change product visibility after saving product from backend using plugin.
For this I have created custom module and plugin, but I am not sure that we can achieve this using of plugin or not? Or Should I go with Observer?
I am trying something like : -
app/code/Custom/HelloWorld/etc/di.xml
<type name="MagentoCatalogModelProduct">
<plugin name="Custom-HelloWorld-product-model" type="CustomHelloWorldPluginProductPlugin" sortOrder="1" />
</type>
app/code/Custom/HelloWorld/Plugin/ProductPlugin.php
namespace CustomHelloWorldPlugin;
class ProductPlugin
public function beforeSetVisiblity(MagentoCatalogModelProduct $subject, $visiblity)
....
Please suggest. Thanks!
magento2 admin upgrade visibility
magento2 admin upgrade visibility
edited Aug 30 at 6:53
kunj
2,3772421
2,3772421
asked Aug 30 at 6:51
Mr. Nanhe
175
175
yes, you can go with plugin.
â kunj
Aug 30 at 6:54
1
Thanks for your suggestion. I also have to update DB value as well. Can you please give me any doc links so I can get more information and implement this in our module.
â Mr. Nanhe
Aug 30 at 7:10
Sure, you can learn more from here : mageplaza.com/magento-2-module-development/â¦
â kunj
Aug 30 at 7:10
add a comment |Â
yes, you can go with plugin.
â kunj
Aug 30 at 6:54
1
Thanks for your suggestion. I also have to update DB value as well. Can you please give me any doc links so I can get more information and implement this in our module.
â Mr. Nanhe
Aug 30 at 7:10
Sure, you can learn more from here : mageplaza.com/magento-2-module-development/â¦
â kunj
Aug 30 at 7:10
yes, you can go with plugin.
â kunj
Aug 30 at 6:54
yes, you can go with plugin.
â kunj
Aug 30 at 6:54
1
1
Thanks for your suggestion. I also have to update DB value as well. Can you please give me any doc links so I can get more information and implement this in our module.
â Mr. Nanhe
Aug 30 at 7:10
Thanks for your suggestion. I also have to update DB value as well. Can you please give me any doc links so I can get more information and implement this in our module.
â Mr. Nanhe
Aug 30 at 7:10
Sure, you can learn more from here : mageplaza.com/magento-2-module-development/â¦
â kunj
Aug 30 at 7:10
Sure, you can learn more from here : mageplaza.com/magento-2-module-development/â¦
â kunj
Aug 30 at 7:10
add a comment |Â
1 Answer
1
active
oldest
votes
up vote
3
down vote
accepted
You should use plugin not observer, there is something need to understand that where to use plugin and where to use observers :
Use Plugins :
If you are going to change input, output ( i.e set / save data ) of some function or changing flow of request then should use plugin.
User Observer :
If you are not going to change the flow of request and intended to perform some other action on event then use Observer.
1
Thanks for your kind suggestion. I have to update DB value as well. Can you please give me any doc links so I can get more information and implement this in our module.
â Mr. Nanhe
Aug 30 at 7:04
add a comment |Â
1 Answer
1
active
oldest
votes
1 Answer
1
active
oldest
votes
active
oldest
votes
active
oldest
votes
up vote
3
down vote
accepted
You should use plugin not observer, there is something need to understand that where to use plugin and where to use observers :
Use Plugins :
If you are going to change input, output ( i.e set / save data ) of some function or changing flow of request then should use plugin.
User Observer :
If you are not going to change the flow of request and intended to perform some other action on event then use Observer.
1
Thanks for your kind suggestion. I have to update DB value as well. Can you please give me any doc links so I can get more information and implement this in our module.
â Mr. Nanhe
Aug 30 at 7:04
add a comment |Â
up vote
3
down vote
accepted
You should use plugin not observer, there is something need to understand that where to use plugin and where to use observers :
Use Plugins :
If you are going to change input, output ( i.e set / save data ) of some function or changing flow of request then should use plugin.
User Observer :
If you are not going to change the flow of request and intended to perform some other action on event then use Observer.
1
Thanks for your kind suggestion. I have to update DB value as well. Can you please give me any doc links so I can get more information and implement this in our module.
â Mr. Nanhe
Aug 30 at 7:04
add a comment |Â
up vote
3
down vote
accepted
up vote
3
down vote
accepted
You should use plugin not observer, there is something need to understand that where to use plugin and where to use observers :
Use Plugins :
If you are going to change input, output ( i.e set / save data ) of some function or changing flow of request then should use plugin.
User Observer :
If you are not going to change the flow of request and intended to perform some other action on event then use Observer.
You should use plugin not observer, there is something need to understand that where to use plugin and where to use observers :
Use Plugins :
If you are going to change input, output ( i.e set / save data ) of some function or changing flow of request then should use plugin.
User Observer :
If you are not going to change the flow of request and intended to perform some other action on event then use Observer.
edited Aug 30 at 7:08
Amit Beraâ¦
53.8k1366157
53.8k1366157
answered Aug 30 at 6:58
Naveed
1,6851212
1,6851212
1
Thanks for your kind suggestion. I have to update DB value as well. Can you please give me any doc links so I can get more information and implement this in our module.
â Mr. Nanhe
Aug 30 at 7:04
add a comment |Â
1
Thanks for your kind suggestion. I have to update DB value as well. Can you please give me any doc links so I can get more information and implement this in our module.
â Mr. Nanhe
Aug 30 at 7:04
1
1
Thanks for your kind suggestion. I have to update DB value as well. Can you please give me any doc links so I can get more information and implement this in our module.
â Mr. Nanhe
Aug 30 at 7:04
Thanks for your kind suggestion. I have to update DB value as well. Can you please give me any doc links so I can get more information and implement this in our module.
â Mr. Nanhe
Aug 30 at 7:04
add a comment |Â
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
StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fmagento.stackexchange.com%2fquestions%2f240191%2fmagento-2-how-to-use-plugin-to-change-product-visiblity-after-saving-product-f%23new-answer', 'question_page');
);
Post as a guest
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
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
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
yes, you can go with plugin.
â kunj
Aug 30 at 6:54
1
Thanks for your suggestion. I also have to update DB value as well. Can you please give me any doc links so I can get more information and implement this in our module.
â Mr. Nanhe
Aug 30 at 7:10
Sure, you can learn more from here : mageplaza.com/magento-2-module-development/â¦
â kunj
Aug 30 at 7:10