Skip to main content
OverflowAI is here! AI power for your Stack Overflow for Teams knowledge community. Learn more

Questions tagged [model]

Models contain most of the business logic in Magento modules

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

Trying to override InvoiceSender

I tried to override InvoiceSender (in /app/code/UFS/Sales/Model/Order/Email/Sender/InvoiceSender.php) but it doesn't work and I don't understand why. I added "'created_at_formatted' => $order-&...
Magento_Dev's user avatar
0 votes
1 answer
28 views

Why do some core repositories use a data model in the save function while others use a model?

I have a quick question and this could help me determine what is the good practice using the repositories. To provide an example to the question I ask in the title of this subject, I can take as ...
beluga's user avatar
  • 41
0 votes
0 answers
19 views

CMS module don't have the getExtensionAttriubtes and setExtensionattributes

I am working on REST API for the cms block and adding some custom fields in the cms_block table. However, I didn't see the methods getExtensionAttriubtes and setExtensionAttriubtes in the CMS Block ...
Arshad Muhammad's user avatar
1 vote
1 answer
103 views

Cannot instantiate abstract class Magento\Framework\Data\Collection\AbstractResource

I am getting this error on my homepage after upgrading my Magento version from 2.4.0 to 2.4.6. Error: Cannot instantiate abstract class Magento\Framework\Data\Collection\AbstractResource in /home/...
Tisha Jhanwar's user avatar
0 votes
1 answer
575 views

Magento 2 - Best practices - Helper vs Model : Which one to get config values?

I cannot seem to find an official information about what is the recommended way to retrieve configuration values in Magento 2. I am searching for the recommended way to retrieve values from the ...
Cladiuss's user avatar
  • 1,279
0 votes
1 answer
42 views

Argument 5 passed to Vendor\Module\Model\ResourceModel\PriceResult\Collection\Interceptor::__construct()

I have created a custom module and it's working fine,if I only run php bin/magento setup:upgrade command. However, when I attempt to run php bin/magento s:d:c it raises an exception. Type Error ...
Bushra's user avatar
  • 62
0 votes
3 answers
49 views

Preference Module - When to Pass in Parent Dependencies

I am currently creating a preference module to add additional functionality to \Magento\Catalog\Model\Product and in reviewing some of the tutorials, example below, I noted that dependencies weren't ...
A. Andersen's user avatar
0 votes
1 answer
96 views

Magento2: get values to databse

I'm trying to get values from the popup model of radio buttons into the database and I'm not getting that, what am I doing wrong? BLOCK FILE <?php namespace vendor\ThreeYearOrders\Block; use ...
Bayzel's user avatar
  • 187
0 votes
2 answers
92 views

Override Model File Magento 2

I want to override Magento\PageBuilder\Model\Catalog\Sorting\SimpleOption.php file. Please check the code below, <config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:...
Sunny Rahevar's user avatar
0 votes
3 answers
356 views

Magento 2 - Is it bad practice to directly use SQL in php?

We are using a third party module. They have their own database tables and read out data from it by using direct SQL statements app/code/Company/Foo/Model/Calculator.php ... public function foo($...
Black's user avatar
  • 3,359
1 vote
3 answers
106 views

Help please , Well configured, but i can't get Model in Magento 1.9.4.5

app/code/local/Info/news/Bock/Adminhtml/news/Grid.php <?php class Info_News_Block_Adminhtml_News_Grid extends Mage_Adminhtml_Block_Widget_Grid{ public function __construct(){ ...
abderrahim rida's user avatar
0 votes
1 answer
64 views

Set function not working on Customer\Visitor model for custom column

I am trying to add new custom columns for now online customer grid. I have added new custom columns in customer_visitor table, but I am not able to save data in custom columns. Firstly, I have added ...
Mukesh Khatri's user avatar
1 vote
1 answer
122 views

is it possible to extend the block class in model

Is it possible to extend block class in model? if so, how to do it. please provide me with example. I have inherited model a class from model and i want to inherits class in block using the class i ...
Bayzel's user avatar
  • 187
0 votes
2 answers
857 views

Magento 2: How to add new method in core interface?

I need to add new method to the core interface so I was checking all the Magento forums and came to know that this can be achieved via extension attributes as like in the post Magento 2 : Override ...
MagentoDev's user avatar
0 votes
1 answer
253 views

how to create customer using custom rest api Magento 2.4.4

I have to create custom rest api for create customer programmatically in Magento-2.4.4. so anyone have an idea then share with me.
Deep Shah's user avatar
  • 561
0 votes
1 answer
160 views

Magento Javascript events

How does one discover which Javascript events exist in Magento 2? I need to run some Javascript code in an adminhtml form for a custom module. The code should run after the fields are displayed (i.e. ...
dotancohen's user avatar
  • 1,115
0 votes
1 answer
408 views

Append "Add New" button in Grid Listing, on a Form

A custom module has Foo and Bar Models. In the Foo element's Form, there exists a grid listing of Bar items which belong to that Foo. This is an excerpt from the view/adminhtml/ui_component/...
dotancohen's user avatar
  • 1,115
0 votes
1 answer
36 views

In Model Edit, display filtered grid of another Model

Consider two models, Foo and Bar. The Bar model has a non-nullable field foo_id which is associated with a Foo object. <?xml version="1.0" ?> <schema xmlns:xsi="..." xsi:...
dotancohen's user avatar
  • 1,115
0 votes
1 answer
50 views

PASS DATA FROM MODEL TO BLOCK

Hello guys i get my data from db with API i want to show data in frontend , i can do this this is function, that return an array of data. public function getComputerAttr($customerId) { $...
Max's user avatar
  • 11
0 votes
0 answers
141 views

Customer Session Dont work adequately

i want to get customer id in model, but customer session return null in any case. Someone can help me ? I also try to get customer id in block but doest work !
Max's user avatar
  • 11
0 votes
1 answer
54 views

Where should I connect model-data-access?

I am building a custom feature to create lists of favourite products. For this purpose I have created 2 models: The actual list-entity and a model representing information about a single product. For ...
Hurrpadurr's user avatar
0 votes
1 answer
237 views

Extending custom interface and data model

I have successfully created a custom interface. My model: app/code/Vendor/Samples/Model/Orders.php class Orders extends \Magento\Framework\Model\AbstractModel implements OrdersInterface { ...
Johndd74's user avatar
0 votes
1 answer
69 views

Magento2: How to add data in child table?

I have a custom module with named A and db tab is z ok. now question is my: How to add child table? which is already I have done with PK and FK key constrains. How to add data in created child table ...
Zahid Hussain Magento's user avatar
0 votes
0 answers
577 views

Magento 2 GraphQL How to update custom row

Using Magento 2.4.3 Graphql Able to get, insert and delete a row from the custom table but unable to update(edit) custom row... custom endpoints - mutation { updateCustomMedia(id:7, input: { ...
sumeet bajaj's user avatar
  • 1,296
0 votes
1 answer
431 views

Magento 2 - Make fields in custom form required

I created a custom controller and model where users can save bank payment data information. I added a form where users can change data from the model. Is there a way to reuse the magento code to ...
Black's user avatar
  • 3,359
0 votes
1 answer
153 views

Magento 2 - store bank payment data

We have a debit payment method where the user has to enter some data like his name, IBAN, BIC and the name of the bank. I need to store these pieces of information in our database and automatically ...
Black's user avatar
  • 3,359
0 votes
1 answer
508 views

How to override Model file ConvertToCsv in custom module

Here am trying to override a vendor file that is vendor/magento/module-ui/Model/Export/ConvertToCsv.php etc/di.xml file <config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:...
Praveen Negimani's user avatar
1 vote
2 answers
1k views

Magento 2 : Custom Module Admin Grid is not Showing

My Custom module is working in Magento 2.4.0 but when I installed in Magento 2.4.3 version it's showing below error in grid section. Type Error occurred when creating object: Rh\CategoryGallery\Model\...
sky's user avatar
  • 1,397
0 votes
2 answers
1k views

Magento 2 - Delete from custom Model

I am trying to delete a record in my custom table (custom model). I can do it like this: $mymodel = $this->mycustomFactory->create(); $mymodel->load($id); $mymodel->delete(); But I ...
sulman's user avatar
  • 529
0 votes
1 answer
348 views

How to override a method of a class where the method itself is defined in its parent class, and only called in the current class?

I would like to extend the OrderSender class, located at Magento\Sales\Model\Order\Email\Sender\ and then override the method prepareTemplate($order), this method is actually defined in the Sender ...
Reshad Zazai's user avatar
0 votes
1 answer
4k views

How to override a method in Magento 2

I would like to override a method of a class, but it does not work. The changes added to the method are not used. File \Magento\Sales\Model\Order\Email\Sender.php <?php /** * Copyright © Magento, ...
Reshad Zazai's user avatar
0 votes
2 answers
360 views

Magento 2 applying filters to collection reflects in all phtml

I have applied a filter in a PHTML that loads in headers. The filter is below. In Constructor: \Magento\Catalog\Model\ResourceModel\Category\Collection $collection Block Code: public function ...
Ramesh KR's user avatar
  • 866
0 votes
1 answer
402 views

Custom Model not updating in catalog_product_save_after event

I ran into weird issue. I am trying to update my custom model/table in catalog_product_save_after event but it always creates new entry in the DB instead of updating older one. I'm doing this way : ...
Abdul Samad Abbasi's user avatar
0 votes
0 answers
263 views

Overriding model file of third party extension magento2.3.2: Type Error occurred when creating object

I am using amasty store locator extension. and I am customizing one of the model files of the extension.The file which i want to override is located inside Amasty/Storelocator/model/location.php. But ...
Masumi's user avatar
  • 1
0 votes
1 answer
554 views

Magento 2 admin order grid model filters based on conditions

I have overridden Magento's default order grid controller. I'm trying to apply different filters based on the custom cookie I set. My di.xml <?xml version="1.0"?> <config xmlns:xsi=&...
Ramesh KR's user avatar
  • 866
0 votes
4 answers
4k views

Magento 2: How to get last inserted custom table Id without saving new item?

I want to get the last inserted id to my block without adding new data into the table. I want to use this value to automatically filled in my phtml file. I tried getId and it's not working. I just ...
mage's user avatar
  • 25
0 votes
1 answer
1k views

How to pass current value of Ui form field in js file

I want to pass the value of checkbox in custom js file, I am using UI component to create a chechbox. So I have to pass this value to js file and then use that value in Model. I am not able to pass ...
Arun Sharma's user avatar
  • 1,315
0 votes
1 answer
381 views

Url parameter in magento 2 collection filter

I need to filter Magento 2 custom grid model collection by URL parameter. I have used this below code. protected function _initSelect() { $objectManager = \Magento\Framework\App\...
Ramesh KR's user avatar
  • 866
0 votes
1 answer
548 views

Magento 2 call url param in Model Collection filter

I'm trying to get some data that matches the id in the URL. I have a param in admin URL like below. seller/items/index/id/9/ I'm using the admin UI component which is working fine. My model code ...
Ramesh KR's user avatar
  • 866
0 votes
1 answer
1k views

Get specific columns from Left Join

I am trying to join two tables like below $objectManager = \Magento\Framework\App\ObjectManager::getInstance(); $collection = $objectManager->get('Advance\Module\Model\Method') ->...
Ramesh KR's user avatar
  • 866
0 votes
1 answer
273 views

Override Model from third party vendor in custom theme

I am trying to override a Model from a third Party vendor in a custom-theme. The original file was: /vendor/3rdpartyompany/3rdpartymodule/Model/Formatter/BaseImage.php I copied that file over to: /...
Mario's user avatar
  • 478
0 votes
0 answers
137 views

Not able to add filters on getItemsCollection in admin order page

I am implementing a feature, where I need to filter the order item list in order admin page. I have checked and found the list is getting from method getItemsCollection(). But when I am trying to ...
Gaurav Agrawal's user avatar
0 votes
1 answer
560 views

Magento 2: Class instance

When i printed this print_r(get_class($this->getOrder())); I got this class name Magento\Sales\Model\Order\Interceptor What does this actually mean ? Where is this "Magento\Sales\Model\Order\...
devhs's user avatar
  • 507
0 votes
1 answer
79 views

Need some brief difference about interfaces and model?

As we know save method by using modelfactory is deprecated i just want to know what is the alternative and how it is implemented because i tried API interfaces but at save i got stuck so kindly anyone ...
Asad Ullah's user avatar
  • 1,461
0 votes
2 answers
2k views

Magento 2 :How to override Magento\Sales\Model\Order\Email\Sender.php model?

Is their any way we can override Magento\Sales\Model\Order\Email\Sender.php model in magento 2 module ? I have created below files di.xml <?xml version="1.0"?> <config xmlns:xsi=&...
devhs's user avatar
  • 507
1 vote
1 answer
400 views

How to change model data via plugin

How to make a plugin for a model and turn one of its fields into a different value. For example, in the documentation, they make an after plugin for the model and return a different value. public ...
Alice's user avatar
  • 148
0 votes
1 answer
457 views

ResourceModel->delete() not deleting row in custom table

I am writing a module which imports additional product information into a custom table with SKU as the PK. If there is already a row in the custom table regarding the SKU, i have to delete the old row ...
Max's user avatar
  • 17
0 votes
0 answers
85 views

Cannot Assign Param Value in Model Collection. Magento 2

I'm currently Facing a really strange Issue I'm applying filter on my custom table data in grid by adding function Vendor/Module/Model/ResourceModel/Withdrawal/Grid/Collection.php protected function ...
Asad Khan's user avatar
  • 1,486
0 votes
0 answers
483 views

How to get custom table from data fetch by form id in magento 2.3.1

How to get custom table form table by form_id for custom table in magento 2.3.1? try this but it's not working custom table screen short: Vendor\Module\Block\Form.php <?php namespace Vendor\...
Ravindrasinh Zala's user avatar
1 vote
1 answer
2k views

Magento 2 Category Tree With Multiselect and Text box in Custom Page

I am looking solution to get a Category tree on a custom page and parallel a text box, where the admin user could add some text and in parallel, he can select multiple categories. After adding text ...
akgola's user avatar
  • 2,947

1
2 3 4 5
16