Questions tagged [model]

Models contain most of the business logic in Magento modules

Filter by
Sorted by
Tagged with
0
votes
2answers
33 views

Issue in extending a model magento 2

I want to extend the Magento\ConfigurableProduct\Helper\Product\Options\Loader as per this github issue https://github.com/magento/magento2/issues/21663#issuecomment-477966963 My di.xml file is <?...
1
vote
1answer
39 views

How to get product from custom attribute in Magneto 2?

I have a Custom attribute on Product in which i have save a string i want to get count of those products which have same attribute value in Magento 2 using an Controller or Model.
0
votes
1answer
37 views

How to add Data to Custom table in database using model in magento 2.3.5

I am created one form for contact and i want to insert form data into custom table in database in magento 2.3.5 so can anyone have idea about it then please send me solution. <?php namespace Aspl\...
0
votes
1answer
18 views

Cannot filter the data collection

I'm trying to filter the data collection from 4 hours to now and I have the below code but its not working. public function getWishlistProduct($wishlistid){ $to = date("Y-m-d h:i:s"); $from ...
3
votes
2answers
208 views

What is difference between these models and design patterns used in Magento?

Yes, I know this question has many answers in google, but please clear my confusion. What is the difference between Repository and Factory, and when should We use a Repository vs a Factory in Magento ...
0
votes
1answer
28 views

I want to create column in sales_order table and view custom field on order edit section in magento 2.3.5

I am added one custom field in checkout address form and i want to store that field data in Database and also display this field in admin order edit page in magento 2.3.5, so anyone can have idea ...
0
votes
1answer
13 views

How to add created at and updated at column and update it on values save?

I want to add created_at and updated_at columns in a custom table and update both columns on saving the data.
0
votes
1answer
22 views

How to properly use Model Collection in Magento 2

I'm using Magento 2.3.4 , and i kinda confuse with how to use Magento 2 model correctly or follow the code standard. I have a model collection with database structure like this: brand_id | name | ...
0
votes
2answers
43 views

Magento 2: Model Override not working

I want to modify the code of Magento\Sales\Model\Service\PaymentFailuresService.php. So I'm overriding Model file using the below code but it's not working. etc/di.xml <?xml version="1.0"?> &...
0
votes
1answer
30 views

Load Customer Model by Extension Attribute in Magento 2

How can I load the Customer Model and Collection by Extension Attribute in Magento 2? I've declared an extension attribute in extension_attributes.xml and saved to the Customer Model. Now, How can I ...
0
votes
1answer
20 views

Save data of custom form in db using model

My controller file <?php namespace Afg\Dealerreferral\Controller\Index; use Afg\Dealerreferral\Model\DataFactory; use Magento\Framework\Controller\ResultFactory; class formdata extends \Magento\...
0
votes
0answers
15 views

How to pass data from model file to phtml file?

I want to pass collection from model file and then, get HTML into model file. How to do that? Please help me. Thanks.
0
votes
2answers
69 views

Magento2.3: How to collect the data by time?

I want to collect the records from 10PM to 5AM of wishlist data. I have already created a module and not sure how to filter the records by this timeframe. The wishlist table contains a field called ...
0
votes
0answers
25 views

Shipping method based on City

I'm trying to make my flat rate shipping method appear only for peoples in a specific city. Magento version 2.2.11 My model is: <?php namespace RaphaelCordeiro\CepLimit\Model\Carrier; use Magento\...
1
vote
1answer
22 views

Declaration warning when extending _afterLoad() in AbstractModel

I've created a backend module to which I've added the possibility to set storeview specific data today. That worked and showed up fine. So I'm trying to load and save my storeview data now but it just ...
0
votes
1answer
18 views

how to set group by and order by for custom model collection query in magento 2.3.4

$Custommodel=$this->mycustommodelFactory->create(); $collection = $Custommodel->getCollection()->addFieldToFilter("customer_id",$customerid); $collection->getSelect()->group('...
0
votes
2answers
54 views

How to get data from a model without calling the objectManager in the template

I have a custom Order model, it has a method in it @method int getIncrementId() I have a template to transfer the id of the current order/app/code/Qq/Www/view/frontend/templates/success/index/...
4
votes
1answer
159 views

getCollection return null on custom model collection Magento 2.3.4

I'm creating a custom module to make a model by using mage2gen, I named this model critic: app/code/Vendor/Module/Model/Critic.php namespace Vendor\Module\Model; use Vendor\Module\Api\Data\...
0
votes
1answer
19 views

Magento 2 - Injecting a model into a class? How to?

I have a class where I'd like to inject a model into it, to use the code already created in the model. How would I go about doing this in my class? Thank you.
0
votes
1answer
60 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
30 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
26 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 ...
1
vote
2answers
99 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
30 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
38 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
27 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
45 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
83 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
42 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
328 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
64 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
370 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
109 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
27 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'] != '') { $...
1
vote
0answers
90 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
177 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
46 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
42 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
182 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
26 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
45 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
1answer
130 views

which model extend AbstractExtensibleModel by default

which model extend AbstractExtensibleModel by default so i can use extension attributes with it ?
4
votes
1answer
48 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
36 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
43 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
59 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
226 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
1k 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
120 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
2 3 4 5
15