Questions tagged [model]

Models contain most of the business logic in Magento modules

Filter by
Sorted by
Tagged with
0
votes
1answer
50 views

How can I get pre-hashed password after customer registration

Please note: I understand this would be open to a potential security risk. However, due to the nature of my site, I want to exhaust as many solutions as possible to help stop fraud from taking place. ...
0
votes
1answer
25 views

Magento getData() vs getFieldName() in model

After load('id') function in model, we can get data by either model->getData('field_name') or model->getFieldName(). I know that both functions are provided by DataObject class but what I want ...
2
votes
1answer
25 views

What PHP class executes the SQL to select models and collections from the database?

When I have a PHP model or collection of a Magento entity (such as a product or customer), what PHP class(es) is in charge of constructing and executing the SQL that selects that model or collection ...
0
votes
2answers
49 views

Magento 2.3.3 create popup

How to create a popup? I want to create a popup for every page unless the customer clicked close. I want to show a popup with the cms block content. I am not sure what to do or how to start I have ...
0
votes
0answers
24 views

How can I get data from table using repositories? | Magento 2.x

How can I create repository in magento 2 and than get data from me custom table using this repository? Model of this tables is created.
0
votes
1answer
23 views

How do I check my override Model is working?

I wrote an override to \vendor\magento\module-sales\Model\Order\Pdf\AbstractPdf.php I did enable my override, I did run magento setup, di compile and flush the cache. Everything went smooth. But ...
0
votes
1answer
25 views

Custom column is not updating in customer_entity table

I added custom column 'email_status' in customer_entity table via dc_schema.xml <?xml version="1.0"?> <schema xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:...
5
votes
1answer
34 views

Error Call to a member function beginTransaction() on a non-object when saving to database

I am at a loss, I've tried a lot of stuff but nothing seems to work to get rid of this error. Fatal error: Call to a member function beginTransaction() on a non-object in /home1/powertg2/public_html/...
1
vote
1answer
44 views

Magento 2 How do I override \vendor\magento\module-fedex\Model\Carrier.php?

I want to make changes on vendor\magento\module-fedex\Model\Carrier.php How do I override this core file? I just want this completely override. Like what folder I should create and what files I ...
1
vote
0answers
41 views

Adding data to database [closed]

I'm able to fetch data from custom form but not able to put it in database table. $model = $this->_name->create(); $entity = $this->getRequest()->getParams(); $model->...
1
vote
1answer
86 views

Magento2: How to override customer model file?

I want to override AccountManagement.php in Magento\Customer\Model\AccountManagement.php directory. My di.xml :- <?xml version="1.0"?> <config xmlns:xsi="http://www.w3.org/2001/XMLSchema-...
0
votes
0answers
14 views

Category not being updates for products

I currently have a cronjob plugin running in the background of my magento 2 installation which imports products from an XML file to the db. The code checks if the product exists, and if it does it ...
3
votes
1answer
57 views

Shell script dumps Model source code

Weird things happening. I've written a customized product import script which is executed as a shell script. In this script, I gather some XML input, parse it into an array and then try to import the ...
1
vote
1answer
170 views

Magento 2.3.2: How to override a Inventory Deduction API model?

I want to override below Magento core file vendor/magento/module-inventory-source-deduction-api/Model/SourceDeductionService.php to add code $qty=0; inline 83. I tried by my self but getting an ...
1
vote
2answers
105 views

Magento2.3.1 How to overide Model file?

I am using Magento2.3.1 and i trying to override model in our theme. our model file path app/code/XXXX/General/Model/Layer <?php namespace XXXXX\General\Model\Layer; class FilterList extends \...
0
votes
0answers
26 views

When I post the data ,the data will save repeatedly into database

How to check weather the value is in database when i insert the data $amount_model = Mage::getModel('donations/amount'); if(isset($post_data['amount']) && $post_data['amount'] != '') { $...
0
votes
0answers
30 views

Magento 2: Custom value save in sales_order_grid table

I have a custom column in the sales_order_grid table and want to save some custom values that are not in sales_order table. Too many tutorials are there that populate sales_order table column into ...
0
votes
2answers
114 views

Model file not overriden in Magento 2

I am trying to override Model file in my custom module like below. Vendor/Module/etc/di.xml <?xml version="1.0"?> <config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:...
0
votes
1answer
39 views

Magento 2: Call Controller method from Model

How to call the controller method from model? Or How to programmatically reindexing using API? Here is my code.Below code gives me error like below. { "messages": { "error": [ ...
2
votes
0answers
36 views

What is a alternative for deprecated method \Magento\Framework\EntityManager\EntityMetadataInterface::getEntityConnection

I am currently implementing a SaveHandler class for my custom model like described here. My goal is to save the relations between my custom model and the Store model. There \Magento\Framework\...
0
votes
1answer
77 views

Magento 2: Ui Component - Magento\Customer\Model\Session can't return current customer

I've got an issue using ui component on front in a large module. The model I'm using for my grid is used at several other points. But I discovered my configuration in di.xml is doing some strange ...
0
votes
0answers
21 views

Magento 2.3.X: Get custom attributes in conditions model

I created a custom module in which I need to insert a conditions model that also has custom attributes. So I have this model: namespace Vendor\Module\Model; use Magento\Quote\Model\Quote\Address; ...
1
vote
2answers
44 views

How to output and filter collection using “->where” filter?

I trying to get output from collection using 'where' filter but no result. This is my code: $collection = Mage::getModel('my_work/datanews') ->getCollection() ->...
0
votes
0answers
30 views

Magento 2 : Add a custom attributes to quote

I have a custom quote module, that i would like to modify and add 2 custom fields, The admin quote module is similar to sales order admin pages, so i want override the admin templates and layouts to ...
0
votes
0answers
27 views

Create custom attribute conditions model magento 2

I would like to build a conditions model that shows the attributes with conditions model in a form. I have not found good online tutorials that explain how to deal with the conditions model. <...
0
votes
1answer
69 views

which model extend AbstractExtensibleModel by default

which model extend AbstractExtensibleModel by default so i can use extension attributes with it ?
4
votes
1answer
44 views

Magento 2 What is the fastest way to get construction changes?

Whenever I made any changes on the construction method, I need to do bin/magento setup:di:compile to get any changes on my code. It was wasting my time, how can I get any changes faster than have to ...
0
votes
1answer
34 views

How to Get List of Table Columns?

How can I get all columns all or all attributes on product if there is no data on it? For example this one : How can I get the list of (post_id, name, url_key, post_content, tags, status, ...
1
vote
0answers
33 views

Magento 2 Model getData for field at specific store_id

In my Model I have a method getSummary() E.G: public function getSummary() { return $this->getData(BlogInterface::SUMMARY); } I have 3 stores: en_1,fr_2,de_3 I've only set summary in ...
1
vote
1answer
37 views

Magento 2 - What should repository methods return?

This question has been on my mind for some time. I'm currently writing a repository with the usual methods: save, getById, getList, delete and deleteById. What is the correct return for each method? ...
1
vote
1answer
77 views

Magento 2 - Custom Repository does not create new entity

I create a custom entity and repository. All work well, but the POST API route does not create new entities. But if I call the PUT API route to change a property, it works well. Why my custom ...
4
votes
2answers
805 views

Magento 2: When should we use a ProductRepository, ProductFactory, Product model?

When should we use a ProductRepository, ProductFactory, Product model? vendor/magento/module-catalog/Model/Product.php vendor/magento/module-catalog/Model/ProductRepository.php generated/code/...
0
votes
1answer
43 views

How to add a pay until date to invoice in Magento2?

Please excuse me if I am asking a dumb question, but I am new to Magento and frankly, my first impression is that it is over-designed and poorly documented. Maybe this is part of their business model, ...
1
vote
1answer
151 views

What to replace deprecated Class 'Zend_Rest_Client' with in Magento 2.3?

A module I'm maintaining is not working on Magento 2.3 since Magento apparently deprecated Class 'Zend_Rest_Client' . I don't see any replacement Client listed in their documentation, so I'm a bit ...
0
votes
2answers
87 views

How to resolve “Model LSD method save() detected in loop” in magento 2?

I am getting a warning as a "Model LSD method save() detected in the loop" when I did MEOP2" The issue is on below the line $model->setData($finalData)->save(); Please anyone can help me to ...
1
vote
1answer
111 views

Magento 2.3. How to add data using model?

I have two variants adding data using Model. Which variant is more rignt ? Especially I want to ask about this $slider->setDataChanges(true);in first variant because I must set up _hasDataChanges ...
2
votes
1answer
73 views

factory class duplicate insert check in magento2

I have created a model class as like below. Vendor\Module\Model/Bulider.php namespace Vendor\Module\Model; use Magento\Framework\Exception\QualificationException; class Builder extends \Magento\...
1
vote
1answer
553 views

Magento 2.2 - Fatal error: Uncaught Error: Call to undefined method Magento\Framework\App\ResourceConnection::load()

Fatal error: Uncaught Error: Call to undefined method Magento\Framework\App\ResourceConnection::load() in /var/www/html/magento2_dev/vendor/magento/framework/Model/AbstractModel.php:536 Just adding ...
4
votes
0answers
56 views

How to load Ui-component form data using another column instead of primary field Magento 2?

I have created a form using Ui-component it is working fine while adding new form & edit form. But I would like to do customization as per my requirement. Default Magento Ui form data is display ...
1
vote
1answer
105 views

How to use resultJsonFactory in Model file magento2

I have used below code to print response from my Model file. <?php class CountrylistManagement implements \Vendor\Module\Api\CountrylistManagementInterface { protected $_storeManager; ...
0
votes
1answer
45 views

Magento 2: Get order ID and Date in DHL Shipping Carrier model

I have a requirement to attach the order ID and order date to the xml request (ShipmentRequest) located in /magento/dhl/model/Carrier.php Is there a way to retrieve the order ID linked to this ...
1
vote
0answers
25 views

How can I change multiple entries in DB?

In DB I have Rows: ID NAME PHONE Example: 1 Steave 33333333 2 Joe 77777 I can add and Edit any row, but I want when I click "save everyone" I rewrote all phones on DB example: 1 Steave 33333333 ...
0
votes
1answer
46 views

Magento 2 : Only dependency assignment operations are allowed in constructor. No other operations are allowed

Magento 2 Coding standard provide me Warning My Code is here namespace Namespace\Modulename\Model; use Magento\Framework\App\Request\DataPersistorInterface; use Magento\Ui\DataProvider\...
1
vote
2answers
131 views

Get recently viewed product collection Magento 2.3.1

I have tried this but it is not working. I am getting blank array. Suggestions please, i am stuck. I want to display recently viewed product in owl carousel. But getting no products. protected $...
2
votes
0answers
80 views

di.xml ExtensionPool create/read handlers Conflicts

I am creating extensionpool handlers to save data in multiple tables. There are total 3 tables : 1 : Sliders 2 : SliderItems 3 : SliderSelectedItems When I create/update Slider, list of selected ...
1
vote
1answer
101 views

KnockoutJS Which Model does the Minicart use?

So, i'm very new when it comes to using KnockoutJS but i've been doing some reading around it and to my knowledge each template file has its own corresponding model. However, as i'm looking through ...
2
votes
1answer
624 views

Magento 2 - Difference between Model, ResourceModel. Collection and Repository

I'm studying Magento and I'm confusing about the differences between these four layers. What I have understood is the following: Model Is the entity class with ONLY getters/setters and magic methods....
0
votes
0answers
29 views

Unable to override model class, only this file has problem

I am overriding Worldpay Model class that create xml request file. <?xml version="1.0" encoding="UTF-8"?> <config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:...
0
votes
2answers
109 views

Magento 2 Model Classses are not injecting without Factory in custom module

I am developing an module in Magento 2.I have created helper,Model Fatal error:vendorname\modulename\Model\Testclass class is not exist.I have tried each and everything to resolve this issue but ...
0
votes
2answers
64 views

Error on constructor of a class that extends \Magento\CatalogRule\Model\Rule

Im trying to do a model that extends \Magento\CatalogRule\Model\Rule, but in the contructor the context is giving me a warning: Declaration of overridden method should be compatible with parent class....

1 2 3 4 5 15