Saving a value without triggering aftersave()
I'm not going in detail about what i'm exactly saving because this question is regards all the possible thing you can save with the ->save() function in each repository.
Anyways , when importing data from an API i use the save() method to store the data that i retrieved. Now it seems that that save() will trigger my plugin AfterSave().
Which makes sense right?
But now is the question. The AfterSave() is ment for when a customer or an admin saves an order/product/customer/... and not for when this is triggered over an autosync (cron job).
Is there somewhere where i can put a filter to determine when to use aftersave and when not?
magento2 api save
add a comment |
I'm not going in detail about what i'm exactly saving because this question is regards all the possible thing you can save with the ->save() function in each repository.
Anyways , when importing data from an API i use the save() method to store the data that i retrieved. Now it seems that that save() will trigger my plugin AfterSave().
Which makes sense right?
But now is the question. The AfterSave() is ment for when a customer or an admin saves an order/product/customer/... and not for when this is triggered over an autosync (cron job).
Is there somewhere where i can put a filter to determine when to use aftersave and when not?
magento2 api save
add a comment |
I'm not going in detail about what i'm exactly saving because this question is regards all the possible thing you can save with the ->save() function in each repository.
Anyways , when importing data from an API i use the save() method to store the data that i retrieved. Now it seems that that save() will trigger my plugin AfterSave().
Which makes sense right?
But now is the question. The AfterSave() is ment for when a customer or an admin saves an order/product/customer/... and not for when this is triggered over an autosync (cron job).
Is there somewhere where i can put a filter to determine when to use aftersave and when not?
magento2 api save
I'm not going in detail about what i'm exactly saving because this question is regards all the possible thing you can save with the ->save() function in each repository.
Anyways , when importing data from an API i use the save() method to store the data that i retrieved. Now it seems that that save() will trigger my plugin AfterSave().
Which makes sense right?
But now is the question. The AfterSave() is ment for when a customer or an admin saves an order/product/customer/... and not for when this is triggered over an autosync (cron job).
Is there somewhere where i can put a filter to determine when to use aftersave and when not?
magento2 api save
magento2 api save
edited 24 mins ago
Teja Bhagavan Kollepara
2,94841847
2,94841847
asked Sep 25 '17 at 9:07
SwAt.BeSwAt.Be
1,375624
1,375624
add a comment |
add a comment |
1 Answer
1
active
oldest
votes
This is where the "area" plays a vital role. You can achieve this by carefully adding your plugin in an appropriate area.
Magento 2 has different areas. For example: frontend, admin, web_api etc. If you want to use your plugin only in frontend, then place your plugin in frontend
area and thus you can limit the functionality.
ie placing your di.xml
appcodeNamespaceModuleetcdi.xml -- applies everywhere
appcodeNamespaceModuleetcfrontenddi.xml -- applies only for
frotend appcodeNamespaceModuleetcadminhtmldi.xml -- applies only
for backend side appcodeNamespaceModuleetcweb_apidi.xml --
applies only for apis
will have different effects. So always keep "area" scope while you are codding. This is a powerful feature to avoid unnecessary config loadings and hence vital for performance.
So if i'm right i want to add that to the admin area and the frontend area. And what happends over ssh won't trigger the plugin?
– SwAt.Be
Sep 25 '17 at 9:16
And by areas you mean put my di.xml in the etc/frontend/ || adminhtml/ folder instead of the etc/ folder.
– SwAt.Be
Sep 25 '17 at 9:18
Yes, exactly. For custom commands I believe we can set an area as per our need. I am not sure whether there is an "area" for native commands.
– Rajeev K Tomy
Sep 25 '17 at 9:23
I tried this and it does indeed work great! Thanks , you just reduced my api load by 80% i believe. Big vote up!
– SwAt.Be
Sep 25 '17 at 9:24
Please see my edit too.
– Rajeev K Tomy
Sep 25 '17 at 9:28
|
show 1 more comment
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%2f194564%2fsaving-a-value-without-triggering-aftersave%23new-answer', 'question_page');
}
);
Post as a guest
Required, but never shown
1 Answer
1
active
oldest
votes
1 Answer
1
active
oldest
votes
active
oldest
votes
active
oldest
votes
This is where the "area" plays a vital role. You can achieve this by carefully adding your plugin in an appropriate area.
Magento 2 has different areas. For example: frontend, admin, web_api etc. If you want to use your plugin only in frontend, then place your plugin in frontend
area and thus you can limit the functionality.
ie placing your di.xml
appcodeNamespaceModuleetcdi.xml -- applies everywhere
appcodeNamespaceModuleetcfrontenddi.xml -- applies only for
frotend appcodeNamespaceModuleetcadminhtmldi.xml -- applies only
for backend side appcodeNamespaceModuleetcweb_apidi.xml --
applies only for apis
will have different effects. So always keep "area" scope while you are codding. This is a powerful feature to avoid unnecessary config loadings and hence vital for performance.
So if i'm right i want to add that to the admin area and the frontend area. And what happends over ssh won't trigger the plugin?
– SwAt.Be
Sep 25 '17 at 9:16
And by areas you mean put my di.xml in the etc/frontend/ || adminhtml/ folder instead of the etc/ folder.
– SwAt.Be
Sep 25 '17 at 9:18
Yes, exactly. For custom commands I believe we can set an area as per our need. I am not sure whether there is an "area" for native commands.
– Rajeev K Tomy
Sep 25 '17 at 9:23
I tried this and it does indeed work great! Thanks , you just reduced my api load by 80% i believe. Big vote up!
– SwAt.Be
Sep 25 '17 at 9:24
Please see my edit too.
– Rajeev K Tomy
Sep 25 '17 at 9:28
|
show 1 more comment
This is where the "area" plays a vital role. You can achieve this by carefully adding your plugin in an appropriate area.
Magento 2 has different areas. For example: frontend, admin, web_api etc. If you want to use your plugin only in frontend, then place your plugin in frontend
area and thus you can limit the functionality.
ie placing your di.xml
appcodeNamespaceModuleetcdi.xml -- applies everywhere
appcodeNamespaceModuleetcfrontenddi.xml -- applies only for
frotend appcodeNamespaceModuleetcadminhtmldi.xml -- applies only
for backend side appcodeNamespaceModuleetcweb_apidi.xml --
applies only for apis
will have different effects. So always keep "area" scope while you are codding. This is a powerful feature to avoid unnecessary config loadings and hence vital for performance.
So if i'm right i want to add that to the admin area and the frontend area. And what happends over ssh won't trigger the plugin?
– SwAt.Be
Sep 25 '17 at 9:16
And by areas you mean put my di.xml in the etc/frontend/ || adminhtml/ folder instead of the etc/ folder.
– SwAt.Be
Sep 25 '17 at 9:18
Yes, exactly. For custom commands I believe we can set an area as per our need. I am not sure whether there is an "area" for native commands.
– Rajeev K Tomy
Sep 25 '17 at 9:23
I tried this and it does indeed work great! Thanks , you just reduced my api load by 80% i believe. Big vote up!
– SwAt.Be
Sep 25 '17 at 9:24
Please see my edit too.
– Rajeev K Tomy
Sep 25 '17 at 9:28
|
show 1 more comment
This is where the "area" plays a vital role. You can achieve this by carefully adding your plugin in an appropriate area.
Magento 2 has different areas. For example: frontend, admin, web_api etc. If you want to use your plugin only in frontend, then place your plugin in frontend
area and thus you can limit the functionality.
ie placing your di.xml
appcodeNamespaceModuleetcdi.xml -- applies everywhere
appcodeNamespaceModuleetcfrontenddi.xml -- applies only for
frotend appcodeNamespaceModuleetcadminhtmldi.xml -- applies only
for backend side appcodeNamespaceModuleetcweb_apidi.xml --
applies only for apis
will have different effects. So always keep "area" scope while you are codding. This is a powerful feature to avoid unnecessary config loadings and hence vital for performance.
This is where the "area" plays a vital role. You can achieve this by carefully adding your plugin in an appropriate area.
Magento 2 has different areas. For example: frontend, admin, web_api etc. If you want to use your plugin only in frontend, then place your plugin in frontend
area and thus you can limit the functionality.
ie placing your di.xml
appcodeNamespaceModuleetcdi.xml -- applies everywhere
appcodeNamespaceModuleetcfrontenddi.xml -- applies only for
frotend appcodeNamespaceModuleetcadminhtmldi.xml -- applies only
for backend side appcodeNamespaceModuleetcweb_apidi.xml --
applies only for apis
will have different effects. So always keep "area" scope while you are codding. This is a powerful feature to avoid unnecessary config loadings and hence vital for performance.
edited Dec 19 '17 at 7:52
Goose84
1,27911240
1,27911240
answered Sep 25 '17 at 9:14
Rajeev K TomyRajeev K Tomy
14.4k54585
14.4k54585
So if i'm right i want to add that to the admin area and the frontend area. And what happends over ssh won't trigger the plugin?
– SwAt.Be
Sep 25 '17 at 9:16
And by areas you mean put my di.xml in the etc/frontend/ || adminhtml/ folder instead of the etc/ folder.
– SwAt.Be
Sep 25 '17 at 9:18
Yes, exactly. For custom commands I believe we can set an area as per our need. I am not sure whether there is an "area" for native commands.
– Rajeev K Tomy
Sep 25 '17 at 9:23
I tried this and it does indeed work great! Thanks , you just reduced my api load by 80% i believe. Big vote up!
– SwAt.Be
Sep 25 '17 at 9:24
Please see my edit too.
– Rajeev K Tomy
Sep 25 '17 at 9:28
|
show 1 more comment
So if i'm right i want to add that to the admin area and the frontend area. And what happends over ssh won't trigger the plugin?
– SwAt.Be
Sep 25 '17 at 9:16
And by areas you mean put my di.xml in the etc/frontend/ || adminhtml/ folder instead of the etc/ folder.
– SwAt.Be
Sep 25 '17 at 9:18
Yes, exactly. For custom commands I believe we can set an area as per our need. I am not sure whether there is an "area" for native commands.
– Rajeev K Tomy
Sep 25 '17 at 9:23
I tried this and it does indeed work great! Thanks , you just reduced my api load by 80% i believe. Big vote up!
– SwAt.Be
Sep 25 '17 at 9:24
Please see my edit too.
– Rajeev K Tomy
Sep 25 '17 at 9:28
So if i'm right i want to add that to the admin area and the frontend area. And what happends over ssh won't trigger the plugin?
– SwAt.Be
Sep 25 '17 at 9:16
So if i'm right i want to add that to the admin area and the frontend area. And what happends over ssh won't trigger the plugin?
– SwAt.Be
Sep 25 '17 at 9:16
And by areas you mean put my di.xml in the etc/frontend/ || adminhtml/ folder instead of the etc/ folder.
– SwAt.Be
Sep 25 '17 at 9:18
And by areas you mean put my di.xml in the etc/frontend/ || adminhtml/ folder instead of the etc/ folder.
– SwAt.Be
Sep 25 '17 at 9:18
Yes, exactly. For custom commands I believe we can set an area as per our need. I am not sure whether there is an "area" for native commands.
– Rajeev K Tomy
Sep 25 '17 at 9:23
Yes, exactly. For custom commands I believe we can set an area as per our need. I am not sure whether there is an "area" for native commands.
– Rajeev K Tomy
Sep 25 '17 at 9:23
I tried this and it does indeed work great! Thanks , you just reduced my api load by 80% i believe. Big vote up!
– SwAt.Be
Sep 25 '17 at 9:24
I tried this and it does indeed work great! Thanks , you just reduced my api load by 80% i believe. Big vote up!
– SwAt.Be
Sep 25 '17 at 9:24
Please see my edit too.
– Rajeev K Tomy
Sep 25 '17 at 9:28
Please see my edit too.
– Rajeev K Tomy
Sep 25 '17 at 9:28
|
show 1 more comment
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%2f194564%2fsaving-a-value-without-triggering-aftersave%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