Skip to main content
Share Your Experience: Take the 2024 Developer Survey
21 votes
Accepted

Adding an image form element to an add/edit form

I found a way to do it without requiring a class attached to the field. I mean there is a class attached to the form element but not as a renderer. The column should be defined as this: <field ...
Marius's user avatar
  • 198k
20 votes
Accepted

Best Way to Load a Custom Model in Magento 2

Best practice: via the service contract The best practice is always to use the service contract whenever it's possible. You can find the list of reasons here: Magento 2: what are the benefits of ...
Raphael at Digital Pianism's user avatar
18 votes
Accepted

Magento 2.1: using the entity manager

Currently, we do not recommend to use EntityManager for your entities as it's an unfinished feature and we plan to make configuration more declarative. Ideas of EntityManager are: allow persist Data ...
KAndy's user avatar
  • 20.9k
17 votes
Accepted

Magento 2: what are the benefits of using service contracts?

Benifits of using service contracts, (as per Magento 2 understanding) Service contracts have a number of important functions for Magento 2, such as: Upgrading modules becomes easy. Simplify ...
Rakesh Jesadiya's user avatar
14 votes

What and why is the proper way to load a model

Well, the first step you should check for the model in question is: Is there a Repository Service Contract? If so, use that, because Service Contracts are bound to semantic versioning and will ...
Giel Berkers's user avatar
  • 12.3k
6 votes
Accepted

Magento 2.2.5 : Cant go to execute() in Controller

Make your controller extend \Magento\Framework\App\Action\Action instead of \Magento\Backend\App\Action, that should solve your issue. EDIT : It could also be the case you're trying to hit your ...
Vivek Kumar's user avatar
  • 5,395
5 votes
Accepted

Avoiding save in a loop in mass action

In that case you have to save() your entities, so you'll definitely have to call that method. The native core Magento file you linked is not the only one that does that, especially the mass actions ...
Raphael at Digital Pianism's user avatar
5 votes

Magento 2: what are the benefits of using service contracts?

I think the greatest benefit is that modules can determine which functionality can be used by other modules. In Magento 1 you had helpers that where often kind of misused for this purpose (but that's ...
Giel Berkers's user avatar
  • 12.3k
5 votes
Accepted

UIComponent Form - Spinner showing

Change these nodes (provider, deps )to this format: {file_name}.{file_name}_data_source.
Eugene Kapelko's user avatar
5 votes
Accepted

How to Create CRUD operations with Admin Grid in Magento 2

Create the CRUD operations with Admin Grid in Magento 2 Step-1 : Choose your Module Name like VendoreName and ModuleName Step-2 : Create a folder like this /app/code/VendoreName/ModuleName Step-3 : ...
Msquare's user avatar
  • 9,103
4 votes
Accepted

Update table use where codition(CRUD) - Magento 2

$cancelId = 5;//id for entry to update $cancel = $this->_cancelFactory->create(); $cancel->load($cancelId); $cancel->setCancelStatus('Review'); $cancel->save(); But as explained in the ...
Marius's user avatar
  • 198k
4 votes
Accepted

Magento 1: most efficient way to bulk add entities

If your entities are not linked to anything else, and the module is for your use only, you can try it with direct inserts. It's certainly the fastest way to do it. $resource = Mage::getSingleton('...
Marius's user avatar
  • 198k
4 votes
Accepted

Can Any one Describe a Basic CRUD Operation in Magento Front Side

After a Long Research i found this full module. Here Namespace is Crud and Module name is Pro First you want to Create Module File. This file is under etc folder Path :- app\etc\modules\Crud_Pro....
Jaimin's user avatar
  • 2,146
3 votes
Accepted

Correct way to save entries to database

Make your class look like this: class ReservedItemRepository implements ReservedItemRepositoryInterface{ protected $collectionFactory; protected $reservedItemFactory; protected $...
Marius's user avatar
  • 198k
3 votes
Accepted

Delete a row by custom field in Magento

No need to load the entire entities it is not optimal in terms of performance. You should use collections instead: $collection = Mage::getResourceModel('xxxxxxxxxx/xxxxxxxxxx_collection')->...
Raphael at Digital Pianism's user avatar
3 votes

Delete a row by custom field in Magento

Here ->load($quote->getId(),'quote_id') may return multiple rows, so if you do ->delete() on this collection, ONLY first row will be deleted. You should loop through the collection for ...
Anil Suthar's user avatar
  • 4,731
3 votes
Accepted

Adding input prefix in an admin form

How can I control dataScope? If you want to control whole name of POST key (like prefix[name]) on Field level then you'll interested in discard autocomposing it. First of all how it composed? When a ...
Anton Huz's user avatar
  • 350
3 votes

Magento 2.2.5 : Cant go to execute() in Controller

Try this code : <?php namespace Fudu\HelloWorld\Controller\Adminhtml\Student; class Create extends \Magento\Backend\App\Action { public function __construct( \Magento\Backend\App\...
Rohan Hapani's user avatar
  • 17.4k
3 votes

Magento 2.2.5 : Cant go to execute() in Controller

You can't grant permission for new admin user on this controller, because when you extend Magento\Framework\App\Action\Action that mean by passing Magento Access Control list. Please re-check these ...
HoangHieu's user avatar
  • 1,358
3 votes
Accepted

Magento 2.2.5: Add Student Instead of Update Student

$model->setData($data); this line reset your data. If there id field present $data variable then your code working fine. Otherwise you need to set id for update. Check following code: $id = $this->...
Sohel Rana's user avatar
  • 35.9k
3 votes

Magento2: Can anyone describe crud operation?

To understand CRUD Operation. you can refer below link, where crud explanation is quite good and simple. http://bilalusean.com/create-read-update-delete-crud-magento-2/
Balwant Singh's user avatar
2 votes

Adding an image form element to an add/edit form

Yes, the class you should extend is \Magento\Ui\Component\Form\Element\AbstractElement. This class implements the ElementInterface which itself extends the UiComponentInterface you're referring to. ...
Raphael at Digital Pianism's user avatar
2 votes

Example of Code and Configuration Needed for a Simple Magento 2 CRUD Model?

For Magento 2. I'm using below CRUD generator https://mage2gen.com/
Jackson's user avatar
  • 9,929
2 votes

Magento 2: what are the benefits of using service contracts?

Benefits of service contract: Enhance the modularity of Magento Ensure a well-defined, durable API that other modules and third-party extensions can implement Make it easy to configure services as ...
Jameslj's user avatar
  • 434
2 votes
Accepted

What is ->load(),->getData() in Magento and how does it work

Well the load() method is a read from the database. first parameter is the id second parameter is the column that will be used as the identifier In your case and assuming that it is a flat entity, ...
Raphael at Digital Pianism's user avatar
2 votes

Magento 2 Custom Module Insert Data Issue

i was facing same problem while trying to save data but further i use this code to save and it was working fine. public function execute() { $data = $this->getRequest()->getPostValue(); ...
Ronak Chauhan's user avatar
2 votes
Accepted

Can Anyone Describe a Basic CRUD Operation of Magento From Admin Side in Magento

I Found the Perfect Answer for that Create Controller from admin side app\code\local\Crud\Pro\controllers\Adminhtml\ProController.php <?php class Crud_Pro_Adminhtml_ProController extends ...
Jaimin's user avatar
  • 2,146
2 votes

What and why is the proper way to load a model

Models are Data Interface are used to only hold the data in objects, i.e to set and get data for a row. ResourceModels are a mechanism which is responsible for the persistence of such data, i.e ...
Milind Singh's user avatar
  • 1,594
2 votes
Accepted

Magento 2.2 CRUD(Add,Update,Delete,Inline Edit) with ui component

Looks like you have something issue with your code while click on add new button but its syntax error so its showing 500 internal server error Now to check what error it is - open your bootstrap.php ...
Manthan Dave's user avatar
  • 9,826
2 votes

Magento 2 : CRUD, Invalid method _getResource() in model when Save

While you provided limited code i can't look into this, But here you go. Setup/InstallSchema.php public function install(\Magento\Framework\Setup\SchemaSetupInterface $setup, \Magento\Framework\...
anonymous's user avatar
  • 3,752

Only top scored, non community-wiki answers of a minimum length are eligible