We’re rewarding the question askers & reputations are being recalculated! Read more.

Questions tagged [model]

Models contain most of the business logic in Magento modules

Filter by
Sorted by
Tagged with
0
votes
0answers
13 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
47 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 ...
0
votes
1answer
80 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
104 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
22 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
18 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
94 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
34 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": [ ...
1
vote
0answers
28 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
40 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
19 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
43 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
26 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
25 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
37 views

which model extend AbstractExtensibleModel by default

which model extend AbstractExtensibleModel by default so i can use extension attributes with it ?
4
votes
1answer
41 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
27 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
31 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
36 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
363 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
29 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
95 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
45 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
71 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
46 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
335 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
49 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
69 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
34 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
39 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
89 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
69 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
50 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
320 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
27 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
85 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
50 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....
2
votes
1answer
57 views

Magento 2.3 - The correct way to get custom attribute

I have added the custom attribute referral_code of type static to the customer entity. The attribute showing up correctly, and I can get/set it in easy way with $customer->getReferralCode() and ...
2
votes
2answers
199 views

How to use a Magento 1 model to update multiple rows?

I am processing some records and I need to set a datetime field to the current time for multiple rows. I have all the row IDs. What's the best way to do this with Magento 1? The SQL would be like this:...
1
vote
1answer
283 views

Magento 2 + Fatal error save() must be an instance interface not a model

Trying to save record in admin grid with create API interface but getting fatal Error link below Fatal error: Uncaught TypeError: Argument 1 passed to Mage2\Inquiry\Model\InquiryRepository::save()...
0
votes
1answer
239 views

How to add expression in collection query magento 2?

I want to write this query into Magento 2 formate SELECT vendor_id, vendor_name, ( 6371 * ACOS( COS( RADIANS( 45.4102961 ) ) * COS( RADIANS( vendor_latitude ) ) * COS( RADIANS( vendor_longitude ) ...
1
vote
1answer
225 views

Getting error after adding arguments in constructor

I have added model in my constructor public function __construct( Context $context, PageFactory $resultPageFactory, \Vendor\Module\Model\Productsgrid $model ) { $this->model = $...
3
votes
1answer
128 views

How to fix this “Running schema recurring.Unique constraint violation found”

How to fix this error "Running schema recurring.Unique constraint violation found". This statement occurs when I used upgrade command of Magento 2 model upgradation.
0
votes
1answer
16 views

Can a product's attribute store several values for the same product or do I have to do something else (Magento 1.9)?

I will explain with general terms the situation: I have some products which should have 1-8 values for the same attribute and in the same product. For example: SKU 55720, Name of Attribute: Norm, ...
6
votes
2answers
170 views

Proper way to call a model constant in Magento 1

I have the class below: class Company_Module_Model_Somemodel extends Mage_Core_Model_Abstract { const SOME_CONST = 'constant_text'; } What is the proper and correct way to call the constant ...
0
votes
1answer
71 views

Magento 2 - Add a new product attribute with values from DB

I'm looking for creating a custom attribute for products, already have a CRUD module, with name and descriptions fields, so the names from my DB should be options of that attribute. How do I need to ...
0
votes
0answers
60 views

Magento 2 Query in custom model file not working

I am working on the Magento 2 custom model file, my table name is custom_log, then I have created the following model file in my module directory. Test/Customlog/Model/Log.php namespace Test\...
0
votes
1answer
43 views

Which one is the difference between Product and ProductRepository?

In Magento 2, which one is the difference between Magento\Catalog\Model\Product and Magento\Catalog\Model\ProductRepository? Using both of them, seems they have the same methods, so I don't know when ...