Linked Questions

0 votes
0 answers
135 views

Magento 2 : The proper way to read/save entities [duplicate]

I have been only for a few days in the Magento universe, starting with Magento 2, and I am currently a bit lost regarding the proper way to read and save entities (Model). At the very begginning, I ...
enrico69's user avatar
  • 515
55 votes
3 answers
31k views

How to implement service contract for a custom module in Magento 2?

As seen in this post : Deprecated save and load methods in Abstract Model the save and load methods are deprecated in the Magento 2 develop branch. Thus, the good practice is now to be implement ...
Raphael at Digital Pianism's user avatar
23 votes
2 answers
38k views

Magento 2.1.1 How to load Order with Increment ID using OrderRepository object

What would be the latest best practice to load Order using increment ID (instead of Order ID) using OrderRepository
frostshoxx's user avatar
16 votes
3 answers
47k views

Magento 2 : How to load quote by quote id

How can I load quote in magento 2 by quote id ?
Krupali's user avatar
  • 1,150
32 votes
2 answers
5k views

Magento 2 - Why is Magento\Checkout\Model\Cart deprecated?

Since Magento 2.1, Cart has a @deprecated tag. Nevertheless, it is still used by Magento itself to store products when shopping. Is the deprecation intended, and if so, and what should we use instead?
Patrick van Bergen's user avatar
20 votes
1 answer
40k views

Magento2 : Best way to load Customer by customer Id

What is the best way to load Customer by Id? using customer interface or customer factory or another way ? In most of solutions I found, it is done by directly using objectManager (which should be ...
Vishwas Bhatnagar's user avatar
19 votes
2 answers
21k views

Best Way to Load a Custom Model in Magento 2

Because it was hard for me to find the right way, below you could find the best practice I made mine. Enjoy, correct my English if needed and say me I'm wrong if I am. :) Edit : ... and I found out I ...
Nicolas PERNOT's user avatar
6 votes
3 answers
14k views

programatically cancel the order using order id - Magento 2

My requirement is programatically change the order status to Canceled by using order id. How to achieve this?
Bilal Usean's user avatar
  • 10.1k
28 votes
1 answer
5k views

Magento 2.1: using the entity manager

From 2.1 Magento has introduced Magento/Framework/Model/EntityManager I may be wrong here but from my understanding it is to replace Magento/Framework/Model/AbstractModel which was implementing the ...
Raphael at Digital Pianism's user avatar
4 votes
5 answers
21k views

Magento 2 - Create product programmatically with different store view values

I have created this custom import module that will create products and set different values for each store view. The problem is, when I save a single attribute for the product on a store view, all the ...
Robban's user avatar
  • 811
5 votes
3 answers
2k views

Save is deprecated when try to create attributes set

I try to create programmatically some attributes set. I find this code : $setup = $this->moduleDataSetup->getConnection(); $setup->startSetup(); $categorySetup = $this->...
Kozame's user avatar
  • 964
0 votes
1 answer
4k views

Update table use where codition(CRUD) - Magento 2

I need to update particular field in table using CRUD operation of Magento. I have tried below for insert new record it is working $this->_cancelFactory->create()->setData(array('...
Bilal Usean's user avatar
  • 10.1k
4 votes
2 answers
692 views

Magento 2 - what functions can I use?

Recently I've went through the "Fundamentals of Magento 2 development" course and there was such statement that we SHOULD NOT use functions from other modules that are not defined in the API ...
Sebastian's user avatar
  • 518
6 votes
1 answer
2k views

Annotating methods in API interfaces to work with DataObjectHelper::populateWithArray

I'm trying to build a proper CRUD module for Magento 2. My module contains for now an entity called Author. This module contains the main entity table and a many to many relations table with the store ...
Marius's user avatar
  • 199k
1 vote
2 answers
3k views

Saving a Quote Since Save() is Deprecated

I have created a new attribute for quotes and orders in Magento 2.1.5. I have an observer that sets the value for this attribute based on a session variable (indentOrder). The code I have is working:...
Wildcard27's user avatar
2 votes
3 answers
548 views

Difference between load() and get() methods

While going through the Magento code I have been seeing a lot of instances of: $objectName->load($foo) or $objectName->get($foo) and I was wondering, what is the difference between the 'load'...
Degnan's user avatar
  • 99
2 votes
2 answers
503 views

How to save an EAV entity from controller?

I'm trying to build a custom module that contains an EAV entity in Magento 2 for learning purposes. I have troubles performing a proper save from an admin controller. I'm trying to avoid code like: $...
Marius's user avatar
  • 199k
0 votes
2 answers
973 views

how to use model in magento 2

<?php $price_rules = Mage::getModel('startupready_priceRules/quantitybreaks'); $price_rules->load($priceRuleList); $price_rules->getPricingTables(); ?> Is there any way to use ...
Yudi's user avatar
  • 616
4 votes
1 answer
370 views

Reference for Magento2 best practices

First of all this might not be the right place to ask this question, if this is the case please let me know where the right place is? Currently there is the module best practice reference on http://...
Martijn Schot's user avatar