Questions tagged [model]

Models contain most of the business logic in Magento modules

Filter by
Sorted by
Tagged with
0
votes
0answers
13 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 ...
0
votes
0answers
33 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\...
0
votes
1answer
29 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 ...
0
votes
1answer
19 views

Getting current page type in model?

Magento 2.3.4 Is it somehow possible to get the current page in a model? I am using some sort of page speed optimizer and want to disable some of its features on the product page. I checked the code ...
0
votes
2answers
16 views

Magento 2 - How to properly load quote model by quote id?

I used to load the quote like this: $quote = $this->quoteModel->load($quoteId); But now I get a warning in PhpStorm saying that this method is deprecated: Deprecated: 100.1.0 because entities ...
0
votes
3answers
55 views

Magento 2 - Check if record with certain value already exist in table before creating it

I created a new table company_shipping_quote. I am writing data into it like this: $quoteId = $quote->getId(); $html = $this->_generateNote($expressRule); $quoteModel = $this->...
0
votes
2answers
34 views

Magento 2 - Created new table and model - but model does not save!

I created a new table company_shipping_quote and new models by using https://mage2gen.com/. But how can I create a new object and save it so that it appears in the database? Models: Company/Shipping/...
0
votes
0answers
14 views

Magento 2 Async WebAPI: Data in topic must be of type mixed. array given

I'm using magento v2.3.4 and created a Magento 2 rest webapi function like this: /** * POST for create brands api * @param mixed $data * @return array */ public function create($data); I usually ...
0
votes
0answers
38 views

What is load method in magento 2 model how it's works with magento 2 model

i have doubt in Magento 2 Model when i use this in some places not getting brand value (Graphql Resolver) like cart details $product=$value['model']; $brand=$product->getAttributeText(self::...
0
votes
1answer
29 views

Magento 2 how to insert data in custom table?

I'm getting an error everytime I send my form in order to store data in a custom table I created. This is the error: {"0":"M\u00e9todo no v\u00e1lido Transom\\Emall\\Model\\StoreOwner::...
0
votes
1answer
19 views

in magento controller file there is one get function is there “$mobile -> $model ->getphone();” where is that get phone method defined

in magento custom module controller file there is one get function is there for getting a phone number "$mobile -> $model ->getphone();" where is that get phone method defined.
1
vote
1answer
31 views

What is the fastest way to get 'is_active' column value from 'customer_entity" table?

I'd like to ask for the fastest way to get the column value of 'is_active' from 'customer_entity' table. It could be using object_manager or something. Thank you in advance
0
votes
1answer
16 views

Magento 2 - How to find out which data is available for an object?

I have a quote item: /** * @var \Magento\Quote\Model\QuoteFactory */ protected $_cartFactory; public function __construct( ... \Magento\Checkout\Model\CartFactory $cartFactory, ... ) { ...
0
votes
1answer
50 views

How to save custom table data in Magento 2?

I have created a table using a Controller and Model and in that file show some data. But i don't know how to save that data in database i have created a table in Magento 2 db. But don't understand how ...
0
votes
2answers
39 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
44 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
74 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
22 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
229 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
170 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
21 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
26 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
73 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
49 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
47 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
17 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
105 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
42 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
23 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
30 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
57 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
274 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
25 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
63 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
38 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
27 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
169 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
1answer
117 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
35 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
48 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
107 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
43 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
493 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-...
3
votes
1answer
67 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
558 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
113 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
168 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
245 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
71 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
2 3 4 5
15