Deprecated save and load methods in Abstract Model Planned maintenance scheduled April 17/18, 2019 at 00:00UTC (8:00pm US/Eastern) Announcing the arrival of Valued Associate #679: Cesar Manara Unicorn Meta Zoo #1: Why another podcast?Magento 2 : The proper way to read/save entitiesHow to implement service contract for a custom module in Magento 2?Magento 2.1.1 How to load Order with Increment ID using OrderRepository objectMagento 2 - Why is MagentoCheckoutModelCart deprecated?Magento 2 : How to load quote by quote idBest Way to Load a Custom Model in Magento 2Magento 2.1: using the entity managerMagento2 : Best way to load Customer by customer IdMagento 2 - Create product programmatically with different store view valuesprogramatically cancel the order using order id - Magento 2what is paygate folder in magento core payment module?Injecting Dependencies into a Magento 2 CRUD/Abstract ModelAbstract Resource Model classesHow to implement service contract for a custom module in Magento 2?Constructor integrity testsMagento 2 : The proper way to read/save entitiesBest Way to Load a Custom Model in Magento 2What is the proper way of implementing service contracts in Magento 2?What and why is the proper way to load a modelCorrect way to save entries to database
Is there a documented rationale why the House Ways and Means chairman can demand tax info?
Did the new image of black hole confirm the general theory of relativity?
Slither Like a Snake
Stars Make Stars
What computer would be fastest for Mathematica Home Edition?
Cold is to Refrigerator as warm is to?
Why don't the Weasley twins use magic outside of school if the Trace can only find the location of spells cast?
What do you call a plan that's an alternative plan in case your initial plan fails?
How many things? AとBがふたつ
Replacing HDD with SSD; what about non-APFS/APFS?
How can you insert a "times/divide" symbol similar to the "plus/minus" (±) one?
Typsetting diagram chases (with TikZ?)
What would be Julian Assange's expected punishment, on the current English criminal law?
What LEGO pieces have "real-world" functionality?
What's the point in a preamp?
How to rotate it perfectly?
How to set letter above or below the symbol?
Training a classifier when some of the features are unknown
3 doors, three guards, one stone
Stopping real property loss from eroding embankment
Why is there no army of Iron-Mans in the MCU?
I'm having difficulty getting my players to do stuff in a sandbox campaign
How to politely respond to generic emails requesting a PhD/job in my lab? Without wasting too much time
Stop battery usage [Ubuntu 18]
Deprecated save and load methods in Abstract Model
Planned maintenance scheduled April 17/18, 2019 at 00:00UTC (8:00pm US/Eastern)
Announcing the arrival of Valued Associate #679: Cesar Manara
Unicorn Meta Zoo #1: Why another podcast?Magento 2 : The proper way to read/save entitiesHow to implement service contract for a custom module in Magento 2?Magento 2.1.1 How to load Order with Increment ID using OrderRepository objectMagento 2 - Why is MagentoCheckoutModelCart deprecated?Magento 2 : How to load quote by quote idBest Way to Load a Custom Model in Magento 2Magento 2.1: using the entity managerMagento2 : Best way to load Customer by customer IdMagento 2 - Create product programmatically with different store view valuesprogramatically cancel the order using order id - Magento 2what is paygate folder in magento core payment module?Injecting Dependencies into a Magento 2 CRUD/Abstract ModelAbstract Resource Model classesHow to implement service contract for a custom module in Magento 2?Constructor integrity testsMagento 2 : The proper way to read/save entitiesBest Way to Load a Custom Model in Magento 2What is the proper way of implementing service contracts in Magento 2?What and why is the proper way to load a modelCorrect way to save entries to database
.everyoneloves__top-leaderboard:empty,.everyoneloves__mid-leaderboard:empty,.everyoneloves__bot-mid-leaderboard:empty margin-bottom:0;
I see that in the develop branch of the Magento 2 repo the methods load
and save
from MagentoFrameworkModelAbstractModel
class are deprecated.
But there are a gazillion classes in the core that extend this class and use save
and load
.
When creating my own module for the CRUD part of my entities I follow the same guidelines as a core module does.
But since these methods are deprecated I would rather be prepared for the future.
What should I use instead of them? Or I should extend something else?
magento2 model magento-2.0 magento-2.0.5 deprecated
add a comment |
I see that in the develop branch of the Magento 2 repo the methods load
and save
from MagentoFrameworkModelAbstractModel
class are deprecated.
But there are a gazillion classes in the core that extend this class and use save
and load
.
When creating my own module for the CRUD part of my entities I follow the same guidelines as a core module does.
But since these methods are deprecated I would rather be prepared for the future.
What should I use instead of them? Or I should extend something else?
magento2 model magento-2.0 magento-2.0.5 deprecated
Are these methods are deprecated now?
– Knight017
Jan 18 at 9:43
1
If, by now you mean 2.3, yes they are: github.com/magento/magento2/blob/2.3/lib/internal/Magento/…
– Marius♦
Jan 18 at 10:00
add a comment |
I see that in the develop branch of the Magento 2 repo the methods load
and save
from MagentoFrameworkModelAbstractModel
class are deprecated.
But there are a gazillion classes in the core that extend this class and use save
and load
.
When creating my own module for the CRUD part of my entities I follow the same guidelines as a core module does.
But since these methods are deprecated I would rather be prepared for the future.
What should I use instead of them? Or I should extend something else?
magento2 model magento-2.0 magento-2.0.5 deprecated
I see that in the develop branch of the Magento 2 repo the methods load
and save
from MagentoFrameworkModelAbstractModel
class are deprecated.
But there are a gazillion classes in the core that extend this class and use save
and load
.
When creating my own module for the CRUD part of my entities I follow the same guidelines as a core module does.
But since these methods are deprecated I would rather be prepared for the future.
What should I use instead of them? Or I should extend something else?
magento2 model magento-2.0 magento-2.0.5 deprecated
magento2 model magento-2.0 magento-2.0.5 deprecated
edited Oct 23 '18 at 9:12
Marius
asked May 11 '16 at 14:01
Marius♦Marius
168k28324692
168k28324692
Are these methods are deprecated now?
– Knight017
Jan 18 at 9:43
1
If, by now you mean 2.3, yes they are: github.com/magento/magento2/blob/2.3/lib/internal/Magento/…
– Marius♦
Jan 18 at 10:00
add a comment |
Are these methods are deprecated now?
– Knight017
Jan 18 at 9:43
1
If, by now you mean 2.3, yes they are: github.com/magento/magento2/blob/2.3/lib/internal/Magento/…
– Marius♦
Jan 18 at 10:00
Are these methods are deprecated now?
– Knight017
Jan 18 at 9:43
Are these methods are deprecated now?
– Knight017
Jan 18 at 9:43
1
1
If, by now you mean 2.3, yes they are: github.com/magento/magento2/blob/2.3/lib/internal/Magento/…
– Marius♦
Jan 18 at 10:00
If, by now you mean 2.3, yes they are: github.com/magento/magento2/blob/2.3/lib/internal/Magento/…
– Marius♦
Jan 18 at 10:00
add a comment |
4 Answers
4
active
oldest
votes
You should use Module Service Contract.
For example for product you should use ProductRepositoryInterface
If Module Service Contract is not available you can use ResourceModel to save entities.
I see. This makes sense. But can you confirm that all the core CRUD modules will have service contracts at one point?
– Marius♦
May 12 '16 at 6:10
1
I see that the implementation ofProductRepositoryInterface
still usesload
in the methodsget
andgetById
. Should I use the resource model for my module instead of thisload
method?
– Marius♦
May 12 '16 at 9:05
2
yes, for your module better to use ResourceModel in your Module SL
– KAndy
May 12 '16 at 10:39
5
can you please give some example code for how we can use ResourceModel
– Yogesh Karodiya
Nov 8 '16 at 9:45
1
Do you have any examples? I looked at the official review and newsletter modules, and they are calling "save" directly. I cannot find an example of using ResourceModel. I have it defined for my module, but how to use it?
– Jānis Elmeris
Nov 15 '17 at 15:38
|
show 5 more comments
From what I understood, what is going to happen is Magento is going to switch to hydrators with extract()
and hydrate()
methods.
This link used to work but it seems like Magento team rolled it back: https://github.com/magento/magento2/blob/develop/lib/internal/Magento/Framework/Model/Entity/EntityHydrator.php
You can find the history of the commit here though: https://github.com/magento/magento2/tree/09132da06e18dde0f90aabfc962db2bc19b64f3c/lib/internal/Magento/Framework/Model/Entity
The important files are:
EntityHydrator.php
EntityMetadata.php
HydratorInterface.php
MetadataPool.php
I also suggest you check out the files under the Action
folder as well as the Sequence
files.
From what I understood (I may be totally wrong here):
- the files under the
Action
folder are CRUD actions - the
Sequence
files are iterators ?
That was a conversation that happened a while ago (was it Alan Storm who mentionned it ? can't remember) so I'm not sure if Magento team is still going that way.
Update
From my research, the internal Magento ticket regarding this change is MAGETWO-50676, here are the related commits I managed to find:
- https://github.com/magento/magento2/commit/d57c81ced2419cde9d8af2f55062a783ec6a7789
- https://github.com/magento/magento2/commit/35d2da47a20e978c1cb970db79ee4ea60de56353
- https://github.com/magento/magento2/commit/074b3abc6803454542ff0527110e575309c42466
There's probably more TBH but I don't feel like browsing the entire repo for commit messages ^^
If you're not familiar with hydrators, I suggest you check that link out: http://www.webconsults.eu/blog/entry/108-What_is_a_Hydrator_in_Zend_Framework_2
Update from 2.1
Magento is now using the EntityManager
class to replace the inheritance you can find more information here: Magento 2.1: using the entity manager
1
Ok. Nice theory. But I could use an example from the core. I'm sorry, but my magento skills resume to copy/paste/replace :). You mentioned Action and Sequence files. Can you be more specific?
– Marius♦
May 11 '16 at 14:14
@Marius unfortunately that's all I know. I can't remember where I got that info from but the plan at that time was to use this particular commit: github.com/magento/magento2/tree/… to implement the switch fromload()/save()
to hydrators. I assumeSequences
work like iterators andActions
are CRUD actions
– Raphael at Digital Pianism
May 11 '16 at 14:16
4
you find an example in the current cms block resource model load method: github.com/magento/magento2/blob/develop/app/code/Magento/Cms/… It uses the entityManager->load github.com/magento/magento2/blob/develop/lib/internal/Magento/… which executes a ReadMain operation (I think) github.com/magento/magento2/blob/develop/lib/internal/Magento/… which hydrates the skeleton entity with the loaded entity data (nice move from Magento ;))
– David Verholen
May 17 '16 at 19:23
add a comment |
See description in the class code https://github.com/magento/magento2/blob/2.1/lib/internal/Magento/Framework/Model/AbstractModel.php#L626
1
Any idea whenload
save
anddelete
are going to go away?
– Marius♦
Jun 22 '17 at 6:02
1
They will stay for 2-3 minor releases
– Anton Kril
Jun 24 '17 at 19:53
add a comment |
An alternative to Magento 2 Deprecated Load Method is the resource model load method.
public funtion getCustomer($id)
$customerModel = $this->customerFactory->create();
$this->customerResource->load($customerModel, $id);
$customerModel->getEmail();
here the first parameter is the model object and the second parameter is id you want to load.
An alternative to Magento 2 Deprecated Save Method is the resource model save method.
public funtion save($taskData)
$taskModel = $this->taskFactory->create()->setData($taskData);
$this->resource->save($taskModel);
save method accepts only one parameter that is your model object.
more information available here
add a 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%2f114929%2fdeprecated-save-and-load-methods-in-abstract-model%23new-answer', 'question_page');
);
Post as a guest
Required, but never shown
4 Answers
4
active
oldest
votes
4 Answers
4
active
oldest
votes
active
oldest
votes
active
oldest
votes
You should use Module Service Contract.
For example for product you should use ProductRepositoryInterface
If Module Service Contract is not available you can use ResourceModel to save entities.
I see. This makes sense. But can you confirm that all the core CRUD modules will have service contracts at one point?
– Marius♦
May 12 '16 at 6:10
1
I see that the implementation ofProductRepositoryInterface
still usesload
in the methodsget
andgetById
. Should I use the resource model for my module instead of thisload
method?
– Marius♦
May 12 '16 at 9:05
2
yes, for your module better to use ResourceModel in your Module SL
– KAndy
May 12 '16 at 10:39
5
can you please give some example code for how we can use ResourceModel
– Yogesh Karodiya
Nov 8 '16 at 9:45
1
Do you have any examples? I looked at the official review and newsletter modules, and they are calling "save" directly. I cannot find an example of using ResourceModel. I have it defined for my module, but how to use it?
– Jānis Elmeris
Nov 15 '17 at 15:38
|
show 5 more comments
You should use Module Service Contract.
For example for product you should use ProductRepositoryInterface
If Module Service Contract is not available you can use ResourceModel to save entities.
I see. This makes sense. But can you confirm that all the core CRUD modules will have service contracts at one point?
– Marius♦
May 12 '16 at 6:10
1
I see that the implementation ofProductRepositoryInterface
still usesload
in the methodsget
andgetById
. Should I use the resource model for my module instead of thisload
method?
– Marius♦
May 12 '16 at 9:05
2
yes, for your module better to use ResourceModel in your Module SL
– KAndy
May 12 '16 at 10:39
5
can you please give some example code for how we can use ResourceModel
– Yogesh Karodiya
Nov 8 '16 at 9:45
1
Do you have any examples? I looked at the official review and newsletter modules, and they are calling "save" directly. I cannot find an example of using ResourceModel. I have it defined for my module, but how to use it?
– Jānis Elmeris
Nov 15 '17 at 15:38
|
show 5 more comments
You should use Module Service Contract.
For example for product you should use ProductRepositoryInterface
If Module Service Contract is not available you can use ResourceModel to save entities.
You should use Module Service Contract.
For example for product you should use ProductRepositoryInterface
If Module Service Contract is not available you can use ResourceModel to save entities.
edited Feb 17 '18 at 11:50
answered May 11 '16 at 17:40
KAndyKAndy
16.1k23245
16.1k23245
I see. This makes sense. But can you confirm that all the core CRUD modules will have service contracts at one point?
– Marius♦
May 12 '16 at 6:10
1
I see that the implementation ofProductRepositoryInterface
still usesload
in the methodsget
andgetById
. Should I use the resource model for my module instead of thisload
method?
– Marius♦
May 12 '16 at 9:05
2
yes, for your module better to use ResourceModel in your Module SL
– KAndy
May 12 '16 at 10:39
5
can you please give some example code for how we can use ResourceModel
– Yogesh Karodiya
Nov 8 '16 at 9:45
1
Do you have any examples? I looked at the official review and newsletter modules, and they are calling "save" directly. I cannot find an example of using ResourceModel. I have it defined for my module, but how to use it?
– Jānis Elmeris
Nov 15 '17 at 15:38
|
show 5 more comments
I see. This makes sense. But can you confirm that all the core CRUD modules will have service contracts at one point?
– Marius♦
May 12 '16 at 6:10
1
I see that the implementation ofProductRepositoryInterface
still usesload
in the methodsget
andgetById
. Should I use the resource model for my module instead of thisload
method?
– Marius♦
May 12 '16 at 9:05
2
yes, for your module better to use ResourceModel in your Module SL
– KAndy
May 12 '16 at 10:39
5
can you please give some example code for how we can use ResourceModel
– Yogesh Karodiya
Nov 8 '16 at 9:45
1
Do you have any examples? I looked at the official review and newsletter modules, and they are calling "save" directly. I cannot find an example of using ResourceModel. I have it defined for my module, but how to use it?
– Jānis Elmeris
Nov 15 '17 at 15:38
I see. This makes sense. But can you confirm that all the core CRUD modules will have service contracts at one point?
– Marius♦
May 12 '16 at 6:10
I see. This makes sense. But can you confirm that all the core CRUD modules will have service contracts at one point?
– Marius♦
May 12 '16 at 6:10
1
1
I see that the implementation of
ProductRepositoryInterface
still uses load
in the methods get
and getById
. Should I use the resource model for my module instead of this load
method?– Marius♦
May 12 '16 at 9:05
I see that the implementation of
ProductRepositoryInterface
still uses load
in the methods get
and getById
. Should I use the resource model for my module instead of this load
method?– Marius♦
May 12 '16 at 9:05
2
2
yes, for your module better to use ResourceModel in your Module SL
– KAndy
May 12 '16 at 10:39
yes, for your module better to use ResourceModel in your Module SL
– KAndy
May 12 '16 at 10:39
5
5
can you please give some example code for how we can use ResourceModel
– Yogesh Karodiya
Nov 8 '16 at 9:45
can you please give some example code for how we can use ResourceModel
– Yogesh Karodiya
Nov 8 '16 at 9:45
1
1
Do you have any examples? I looked at the official review and newsletter modules, and they are calling "save" directly. I cannot find an example of using ResourceModel. I have it defined for my module, but how to use it?
– Jānis Elmeris
Nov 15 '17 at 15:38
Do you have any examples? I looked at the official review and newsletter modules, and they are calling "save" directly. I cannot find an example of using ResourceModel. I have it defined for my module, but how to use it?
– Jānis Elmeris
Nov 15 '17 at 15:38
|
show 5 more comments
From what I understood, what is going to happen is Magento is going to switch to hydrators with extract()
and hydrate()
methods.
This link used to work but it seems like Magento team rolled it back: https://github.com/magento/magento2/blob/develop/lib/internal/Magento/Framework/Model/Entity/EntityHydrator.php
You can find the history of the commit here though: https://github.com/magento/magento2/tree/09132da06e18dde0f90aabfc962db2bc19b64f3c/lib/internal/Magento/Framework/Model/Entity
The important files are:
EntityHydrator.php
EntityMetadata.php
HydratorInterface.php
MetadataPool.php
I also suggest you check out the files under the Action
folder as well as the Sequence
files.
From what I understood (I may be totally wrong here):
- the files under the
Action
folder are CRUD actions - the
Sequence
files are iterators ?
That was a conversation that happened a while ago (was it Alan Storm who mentionned it ? can't remember) so I'm not sure if Magento team is still going that way.
Update
From my research, the internal Magento ticket regarding this change is MAGETWO-50676, here are the related commits I managed to find:
- https://github.com/magento/magento2/commit/d57c81ced2419cde9d8af2f55062a783ec6a7789
- https://github.com/magento/magento2/commit/35d2da47a20e978c1cb970db79ee4ea60de56353
- https://github.com/magento/magento2/commit/074b3abc6803454542ff0527110e575309c42466
There's probably more TBH but I don't feel like browsing the entire repo for commit messages ^^
If you're not familiar with hydrators, I suggest you check that link out: http://www.webconsults.eu/blog/entry/108-What_is_a_Hydrator_in_Zend_Framework_2
Update from 2.1
Magento is now using the EntityManager
class to replace the inheritance you can find more information here: Magento 2.1: using the entity manager
1
Ok. Nice theory. But I could use an example from the core. I'm sorry, but my magento skills resume to copy/paste/replace :). You mentioned Action and Sequence files. Can you be more specific?
– Marius♦
May 11 '16 at 14:14
@Marius unfortunately that's all I know. I can't remember where I got that info from but the plan at that time was to use this particular commit: github.com/magento/magento2/tree/… to implement the switch fromload()/save()
to hydrators. I assumeSequences
work like iterators andActions
are CRUD actions
– Raphael at Digital Pianism
May 11 '16 at 14:16
4
you find an example in the current cms block resource model load method: github.com/magento/magento2/blob/develop/app/code/Magento/Cms/… It uses the entityManager->load github.com/magento/magento2/blob/develop/lib/internal/Magento/… which executes a ReadMain operation (I think) github.com/magento/magento2/blob/develop/lib/internal/Magento/… which hydrates the skeleton entity with the loaded entity data (nice move from Magento ;))
– David Verholen
May 17 '16 at 19:23
add a comment |
From what I understood, what is going to happen is Magento is going to switch to hydrators with extract()
and hydrate()
methods.
This link used to work but it seems like Magento team rolled it back: https://github.com/magento/magento2/blob/develop/lib/internal/Magento/Framework/Model/Entity/EntityHydrator.php
You can find the history of the commit here though: https://github.com/magento/magento2/tree/09132da06e18dde0f90aabfc962db2bc19b64f3c/lib/internal/Magento/Framework/Model/Entity
The important files are:
EntityHydrator.php
EntityMetadata.php
HydratorInterface.php
MetadataPool.php
I also suggest you check out the files under the Action
folder as well as the Sequence
files.
From what I understood (I may be totally wrong here):
- the files under the
Action
folder are CRUD actions - the
Sequence
files are iterators ?
That was a conversation that happened a while ago (was it Alan Storm who mentionned it ? can't remember) so I'm not sure if Magento team is still going that way.
Update
From my research, the internal Magento ticket regarding this change is MAGETWO-50676, here are the related commits I managed to find:
- https://github.com/magento/magento2/commit/d57c81ced2419cde9d8af2f55062a783ec6a7789
- https://github.com/magento/magento2/commit/35d2da47a20e978c1cb970db79ee4ea60de56353
- https://github.com/magento/magento2/commit/074b3abc6803454542ff0527110e575309c42466
There's probably more TBH but I don't feel like browsing the entire repo for commit messages ^^
If you're not familiar with hydrators, I suggest you check that link out: http://www.webconsults.eu/blog/entry/108-What_is_a_Hydrator_in_Zend_Framework_2
Update from 2.1
Magento is now using the EntityManager
class to replace the inheritance you can find more information here: Magento 2.1: using the entity manager
1
Ok. Nice theory. But I could use an example from the core. I'm sorry, but my magento skills resume to copy/paste/replace :). You mentioned Action and Sequence files. Can you be more specific?
– Marius♦
May 11 '16 at 14:14
@Marius unfortunately that's all I know. I can't remember where I got that info from but the plan at that time was to use this particular commit: github.com/magento/magento2/tree/… to implement the switch fromload()/save()
to hydrators. I assumeSequences
work like iterators andActions
are CRUD actions
– Raphael at Digital Pianism
May 11 '16 at 14:16
4
you find an example in the current cms block resource model load method: github.com/magento/magento2/blob/develop/app/code/Magento/Cms/… It uses the entityManager->load github.com/magento/magento2/blob/develop/lib/internal/Magento/… which executes a ReadMain operation (I think) github.com/magento/magento2/blob/develop/lib/internal/Magento/… which hydrates the skeleton entity with the loaded entity data (nice move from Magento ;))
– David Verholen
May 17 '16 at 19:23
add a comment |
From what I understood, what is going to happen is Magento is going to switch to hydrators with extract()
and hydrate()
methods.
This link used to work but it seems like Magento team rolled it back: https://github.com/magento/magento2/blob/develop/lib/internal/Magento/Framework/Model/Entity/EntityHydrator.php
You can find the history of the commit here though: https://github.com/magento/magento2/tree/09132da06e18dde0f90aabfc962db2bc19b64f3c/lib/internal/Magento/Framework/Model/Entity
The important files are:
EntityHydrator.php
EntityMetadata.php
HydratorInterface.php
MetadataPool.php
I also suggest you check out the files under the Action
folder as well as the Sequence
files.
From what I understood (I may be totally wrong here):
- the files under the
Action
folder are CRUD actions - the
Sequence
files are iterators ?
That was a conversation that happened a while ago (was it Alan Storm who mentionned it ? can't remember) so I'm not sure if Magento team is still going that way.
Update
From my research, the internal Magento ticket regarding this change is MAGETWO-50676, here are the related commits I managed to find:
- https://github.com/magento/magento2/commit/d57c81ced2419cde9d8af2f55062a783ec6a7789
- https://github.com/magento/magento2/commit/35d2da47a20e978c1cb970db79ee4ea60de56353
- https://github.com/magento/magento2/commit/074b3abc6803454542ff0527110e575309c42466
There's probably more TBH but I don't feel like browsing the entire repo for commit messages ^^
If you're not familiar with hydrators, I suggest you check that link out: http://www.webconsults.eu/blog/entry/108-What_is_a_Hydrator_in_Zend_Framework_2
Update from 2.1
Magento is now using the EntityManager
class to replace the inheritance you can find more information here: Magento 2.1: using the entity manager
From what I understood, what is going to happen is Magento is going to switch to hydrators with extract()
and hydrate()
methods.
This link used to work but it seems like Magento team rolled it back: https://github.com/magento/magento2/blob/develop/lib/internal/Magento/Framework/Model/Entity/EntityHydrator.php
You can find the history of the commit here though: https://github.com/magento/magento2/tree/09132da06e18dde0f90aabfc962db2bc19b64f3c/lib/internal/Magento/Framework/Model/Entity
The important files are:
EntityHydrator.php
EntityMetadata.php
HydratorInterface.php
MetadataPool.php
I also suggest you check out the files under the Action
folder as well as the Sequence
files.
From what I understood (I may be totally wrong here):
- the files under the
Action
folder are CRUD actions - the
Sequence
files are iterators ?
That was a conversation that happened a while ago (was it Alan Storm who mentionned it ? can't remember) so I'm not sure if Magento team is still going that way.
Update
From my research, the internal Magento ticket regarding this change is MAGETWO-50676, here are the related commits I managed to find:
- https://github.com/magento/magento2/commit/d57c81ced2419cde9d8af2f55062a783ec6a7789
- https://github.com/magento/magento2/commit/35d2da47a20e978c1cb970db79ee4ea60de56353
- https://github.com/magento/magento2/commit/074b3abc6803454542ff0527110e575309c42466
There's probably more TBH but I don't feel like browsing the entire repo for commit messages ^^
If you're not familiar with hydrators, I suggest you check that link out: http://www.webconsults.eu/blog/entry/108-What_is_a_Hydrator_in_Zend_Framework_2
Update from 2.1
Magento is now using the EntityManager
class to replace the inheritance you can find more information here: Magento 2.1: using the entity manager
edited Apr 13 '17 at 12:54
Community♦
1
1
answered May 11 '16 at 14:10
Raphael at Digital PianismRaphael at Digital Pianism
55.1k22124279
55.1k22124279
1
Ok. Nice theory. But I could use an example from the core. I'm sorry, but my magento skills resume to copy/paste/replace :). You mentioned Action and Sequence files. Can you be more specific?
– Marius♦
May 11 '16 at 14:14
@Marius unfortunately that's all I know. I can't remember where I got that info from but the plan at that time was to use this particular commit: github.com/magento/magento2/tree/… to implement the switch fromload()/save()
to hydrators. I assumeSequences
work like iterators andActions
are CRUD actions
– Raphael at Digital Pianism
May 11 '16 at 14:16
4
you find an example in the current cms block resource model load method: github.com/magento/magento2/blob/develop/app/code/Magento/Cms/… It uses the entityManager->load github.com/magento/magento2/blob/develop/lib/internal/Magento/… which executes a ReadMain operation (I think) github.com/magento/magento2/blob/develop/lib/internal/Magento/… which hydrates the skeleton entity with the loaded entity data (nice move from Magento ;))
– David Verholen
May 17 '16 at 19:23
add a comment |
1
Ok. Nice theory. But I could use an example from the core. I'm sorry, but my magento skills resume to copy/paste/replace :). You mentioned Action and Sequence files. Can you be more specific?
– Marius♦
May 11 '16 at 14:14
@Marius unfortunately that's all I know. I can't remember where I got that info from but the plan at that time was to use this particular commit: github.com/magento/magento2/tree/… to implement the switch fromload()/save()
to hydrators. I assumeSequences
work like iterators andActions
are CRUD actions
– Raphael at Digital Pianism
May 11 '16 at 14:16
4
you find an example in the current cms block resource model load method: github.com/magento/magento2/blob/develop/app/code/Magento/Cms/… It uses the entityManager->load github.com/magento/magento2/blob/develop/lib/internal/Magento/… which executes a ReadMain operation (I think) github.com/magento/magento2/blob/develop/lib/internal/Magento/… which hydrates the skeleton entity with the loaded entity data (nice move from Magento ;))
– David Verholen
May 17 '16 at 19:23
1
1
Ok. Nice theory. But I could use an example from the core. I'm sorry, but my magento skills resume to copy/paste/replace :). You mentioned Action and Sequence files. Can you be more specific?
– Marius♦
May 11 '16 at 14:14
Ok. Nice theory. But I could use an example from the core. I'm sorry, but my magento skills resume to copy/paste/replace :). You mentioned Action and Sequence files. Can you be more specific?
– Marius♦
May 11 '16 at 14:14
@Marius unfortunately that's all I know. I can't remember where I got that info from but the plan at that time was to use this particular commit: github.com/magento/magento2/tree/… to implement the switch from
load()/save()
to hydrators. I assume Sequences
work like iterators and Actions
are CRUD actions– Raphael at Digital Pianism
May 11 '16 at 14:16
@Marius unfortunately that's all I know. I can't remember where I got that info from but the plan at that time was to use this particular commit: github.com/magento/magento2/tree/… to implement the switch from
load()/save()
to hydrators. I assume Sequences
work like iterators and Actions
are CRUD actions– Raphael at Digital Pianism
May 11 '16 at 14:16
4
4
you find an example in the current cms block resource model load method: github.com/magento/magento2/blob/develop/app/code/Magento/Cms/… It uses the entityManager->load github.com/magento/magento2/blob/develop/lib/internal/Magento/… which executes a ReadMain operation (I think) github.com/magento/magento2/blob/develop/lib/internal/Magento/… which hydrates the skeleton entity with the loaded entity data (nice move from Magento ;))
– David Verholen
May 17 '16 at 19:23
you find an example in the current cms block resource model load method: github.com/magento/magento2/blob/develop/app/code/Magento/Cms/… It uses the entityManager->load github.com/magento/magento2/blob/develop/lib/internal/Magento/… which executes a ReadMain operation (I think) github.com/magento/magento2/blob/develop/lib/internal/Magento/… which hydrates the skeleton entity with the loaded entity data (nice move from Magento ;))
– David Verholen
May 17 '16 at 19:23
add a comment |
See description in the class code https://github.com/magento/magento2/blob/2.1/lib/internal/Magento/Framework/Model/AbstractModel.php#L626
1
Any idea whenload
save
anddelete
are going to go away?
– Marius♦
Jun 22 '17 at 6:02
1
They will stay for 2-3 minor releases
– Anton Kril
Jun 24 '17 at 19:53
add a comment |
See description in the class code https://github.com/magento/magento2/blob/2.1/lib/internal/Magento/Framework/Model/AbstractModel.php#L626
1
Any idea whenload
save
anddelete
are going to go away?
– Marius♦
Jun 22 '17 at 6:02
1
They will stay for 2-3 minor releases
– Anton Kril
Jun 24 '17 at 19:53
add a comment |
See description in the class code https://github.com/magento/magento2/blob/2.1/lib/internal/Magento/Framework/Model/AbstractModel.php#L626
See description in the class code https://github.com/magento/magento2/blob/2.1/lib/internal/Magento/Framework/Model/AbstractModel.php#L626
edited Mar 7 at 6:33
Marius♦
168k28324692
168k28324692
answered Jun 22 '17 at 4:46
Anton KrilAnton Kril
4,0461321
4,0461321
1
Any idea whenload
save
anddelete
are going to go away?
– Marius♦
Jun 22 '17 at 6:02
1
They will stay for 2-3 minor releases
– Anton Kril
Jun 24 '17 at 19:53
add a comment |
1
Any idea whenload
save
anddelete
are going to go away?
– Marius♦
Jun 22 '17 at 6:02
1
They will stay for 2-3 minor releases
– Anton Kril
Jun 24 '17 at 19:53
1
1
Any idea when
load
save
and delete
are going to go away?– Marius♦
Jun 22 '17 at 6:02
Any idea when
load
save
and delete
are going to go away?– Marius♦
Jun 22 '17 at 6:02
1
1
They will stay for 2-3 minor releases
– Anton Kril
Jun 24 '17 at 19:53
They will stay for 2-3 minor releases
– Anton Kril
Jun 24 '17 at 19:53
add a comment |
An alternative to Magento 2 Deprecated Load Method is the resource model load method.
public funtion getCustomer($id)
$customerModel = $this->customerFactory->create();
$this->customerResource->load($customerModel, $id);
$customerModel->getEmail();
here the first parameter is the model object and the second parameter is id you want to load.
An alternative to Magento 2 Deprecated Save Method is the resource model save method.
public funtion save($taskData)
$taskModel = $this->taskFactory->create()->setData($taskData);
$this->resource->save($taskModel);
save method accepts only one parameter that is your model object.
more information available here
add a comment |
An alternative to Magento 2 Deprecated Load Method is the resource model load method.
public funtion getCustomer($id)
$customerModel = $this->customerFactory->create();
$this->customerResource->load($customerModel, $id);
$customerModel->getEmail();
here the first parameter is the model object and the second parameter is id you want to load.
An alternative to Magento 2 Deprecated Save Method is the resource model save method.
public funtion save($taskData)
$taskModel = $this->taskFactory->create()->setData($taskData);
$this->resource->save($taskModel);
save method accepts only one parameter that is your model object.
more information available here
add a comment |
An alternative to Magento 2 Deprecated Load Method is the resource model load method.
public funtion getCustomer($id)
$customerModel = $this->customerFactory->create();
$this->customerResource->load($customerModel, $id);
$customerModel->getEmail();
here the first parameter is the model object and the second parameter is id you want to load.
An alternative to Magento 2 Deprecated Save Method is the resource model save method.
public funtion save($taskData)
$taskModel = $this->taskFactory->create()->setData($taskData);
$this->resource->save($taskModel);
save method accepts only one parameter that is your model object.
more information available here
An alternative to Magento 2 Deprecated Load Method is the resource model load method.
public funtion getCustomer($id)
$customerModel = $this->customerFactory->create();
$this->customerResource->load($customerModel, $id);
$customerModel->getEmail();
here the first parameter is the model object and the second parameter is id you want to load.
An alternative to Magento 2 Deprecated Save Method is the resource model save method.
public funtion save($taskData)
$taskModel = $this->taskFactory->create()->setData($taskData);
$this->resource->save($taskModel);
save method accepts only one parameter that is your model object.
more information available here
answered 8 mins ago
chirag dodiachirag dodia
81931122
81931122
add a comment |
add a 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%2f114929%2fdeprecated-save-and-load-methods-in-abstract-model%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
Are these methods are deprecated now?
– Knight017
Jan 18 at 9:43
1
If, by now you mean 2.3, yes they are: github.com/magento/magento2/blob/2.3/lib/internal/Magento/…
– Marius♦
Jan 18 at 10:00