Stack Exchange Network

Stack Exchange network consists of 174 Q&A communities including Stack Overflow, the largest, most trusted online community for developers to learn, share their knowledge, and build their careers.

Visit Stack Exchange

Models contain most of the business logic in Magento modules

0
votes
0answers
10 views

Developer to Production Cashe

Magento 2.2 Hi all been using MAGE for about 2 months now and I am a Neophyte to front and back end. I am looking for a little guidance in changing form "developer" to "production" mode. I don't use ...
0
votes
1answer
10 views

invalid create method

I have a model, I call it in a block and when I use the create method I get an error saying: Exception #0 (Magento\Framework\Exception\LocalizedException): Invalid method Vendor\Namespace\Model\...
1
vote
1answer
23 views

How to delete the content of a table

I'm able to fetch the single items, or the whole tables via the $modelFactory->create()->load(ID) or $modelFactory->create()->getCollection() Using the $modelFactory, how can I delete all ...
0
votes
0answers
10 views

M2: Can we use Model class in Block and same Block class in Model for sharing values?

I want to use an instance of a Model into a Block and an instance of same Block into same Model. As namespace Demo\HelloWorld\Block; class Seller extends \Magento\Framework\View\Element\Template { ...
2
votes
0answers
34 views

Magento2: How can I set to a model in “specificcountry” on config.xml file?

I want to set default values with a model from declared class in system.xml. The result of the model is extracted from the database, from a custom table and the result looks like this: AF,AL,DE,BE,FR ...
2
votes
1answer
28 views

How to connect Model / Data Model

Vendor/ModuleName/Model/TestModel.php Vendor/ModuleName/Model/Data/TestModel.php Vendor/ModuleName/Model/TestModelRepository.php Interfaces are already created. The Data Model contains for eg. these ...
2
votes
0answers
20 views

Check if 2 dates already exist in collection filtering

i have a custom collection which has database column start_at and end_at in Y-m-d format , i try to do some validation before inserting to database, one of them is make sure the period between ...
0
votes
2answers
48 views

Create simple hello world model

I developed a extension. Now I try to add a model which has a function that returns "hello world". I tried it like seen here. app/code/local/Fekete/Newsletter2Go/etc/config.xml ... <global> ...
2
votes
3answers
147 views

magento 2 : model in custom module

i already have a table in database also created model files and all works fine so now added another table successfully so what changes i need to do with model files i mean in model resourcemodel and ...
1
vote
1answer
12 views

GridFactory getting generated into wrong location

I have a custom module with backend management. I have an observer on config save that uses the file upload to read submitted file to update the collection however this fails due to below; class \My\...
1
vote
0answers
21 views

Magento 2: Migration using models

I would like to migrate products from magento 1 to magento 2 using core models instead of the migration toolkit provided by magento. The reason is that the products need A LOT of modification in the ...
4
votes
3answers
42 views

How to get config data from model in magento 2?

I have code file in model.How to get config data ? I have error with AbstractMethod and getConfigData() in PHP storm .ERROR Class AbstractMethod is deprecated Method getConfigData is ...
0
votes
1answer
25 views

SKU Report for null attribute values

I am getting all product sku's that does not have a attribute value 'image_link'. I have written this code in magento : $products = Mage::getModel('catalog/product') ->getCollection() ->...
0
votes
1answer
22 views

Prevent a model from being saved

I'm trying to prevent a model from being saved by setting Mage_Core_Model_Abstract's _dataSaveAllowed property. This is going to happen inside an overriding Abstract.php file within local pool. app/...
0
votes
0answers
16 views

magento 2 - Overriding Abstract class in model is not working in custom module

I am trying to override the fontsize value for pdfslip file in my module. The pdfslip files can be found in admin under sales->invoices->actions. The function that I am interested in is ...
0
votes
0answers
8 views

What class should I extend for creating data source model of the database field?

I have some a custom entity model that has the some field in a database. I want to use some data source for it for validation and modification value of data. What model can I use for the database ...
2
votes
1answer
85 views

Custom Module data save gives array to string exception in Magento 2

I've made a custom module with a ui component in the admin. It's a grid that is filled with block data. When adding a block, and saving it in Controller/Adminhtml/Content/Save.php, exception "Array ...
0
votes
2answers
36 views

Call to undefined method addFieldToFilter() in magento 2

I have a model,resource model,collection file shown below. app/code/Magge/Custom/Model/Categrory.php namespace Magge\Custom\Model; use Magento\Framework\Model\AbstractModel; class Categrory ...
0
votes
1answer
28 views

Magento 1.9 add attribute to Credit memo item

I am trying to add a quantity to return to stock data to the credit memo item. I have made 2 install scripts. One adds a column to the database <?php $installer = $this; $installer->...
0
votes
0answers
22 views

Getting model data

I have started working with Magento 1.9 a week ago. Whenever I wish to make a module I need to know the field names for different models to fetch them from an observable I've been doing something ...
0
votes
2answers
74 views

Magento 2 Override Model using Plugin

I have to override magento 2 code model file in the custom module. I have to override below method from Magento\Quote\Model\Quote\Address to my custom module and I have to change value of $amount. ...
0
votes
1answer
28 views

Magento 2 model for adding images to media folder (not for products)?

When not working with products, is there a magento2 model/function that can be used for reading/writing images to the media folder? (like addImageToMediaGallery / getMediaGalleryProcessor()->...
1
vote
1answer
12 views

Module with cron job to fetch all products where custom attribute is true

I am brand new to Magento module development, and I need some help getting started. My goal is relatively simple: I'd like to create a module which fetches all products with a custom attribute '...
0
votes
0answers
9 views

Create a detail listing page of a record on admin side

I want to create a page like an edit page of an model where user cannot change any content. He can only see the content. How can i achieve it?
2
votes
2answers
217 views

addAttributeToSelect Call to undefined method M2

I have two custom modules and am calling one collectionfactory in other module and getting ` Call to undefined method addAttributeToSelect Collection file look like class Collection extends \...
2
votes
2answers
78 views

load customer object update issue in magento 2?

I have used below code in my controller use Magento\Customer\Api\Data\CustomerInterfaceFactory; class editPost extends \Magento\Framework\App\Action\Action { protected $_customer; protected $...
0
votes
2answers
35 views

Magento2 Model not loading complete data using Factory

Below is my construct function of controller - public function __construct( \Magento\Framework\App\Action\Context $context, \Magento\Framework\Registry $coreRegistry, \Vendor\...
0
votes
2answers
50 views

Magento 1.9 Override Model Problem

Path File i want Override app\code\community\OtherCompany\core\Model\Api\Rest\Client.php Path my file override app\code\local\MyCompany\MyModule\Model\Api\Rest\Client.php app\etc\modules\...
1
vote
0answers
37 views

get join table's all rows with collection magento2

I am fetching a collection (of user table), that is retrieving correctly. Now I have one more table (ex.- address) that has multiple row related collection table primary key. I want to fetch them all ...
0
votes
0answers
121 views

How to Get recently viewed products collection in Model File ? Magento 2

I have tried this but it is a solution for Block file, I want collection in Model file. Because i want to use it in API Interface.
0
votes
1answer
58 views

Magetno 2 custom module how to Update DB Table row with model

How do I update instead of inserting new row on save using model My code: $question = $this->_objectManager->create('Vendor\HelloWorld\Model\Question'); $question->setTitle('Simple Question'...
0
votes
3answers
217 views

Magento 2 How to get only one field data in collection

I want to get only one field data in my custom module collection. For ex: getting following data in collection: Array ( [0] => Array ( [banner_id] => 1 [banner_title] =...
1
vote
1answer
70 views

Magento 2 - Not able to override CouponManagement Model

I am trying to override Magento\Quote\Model\CouponManagement core vendor file. What I am trying to achieve is change the default error message when the wrong coupon code is added. My di.xml <?...
0
votes
0answers
44 views

How to override ProductRepository model file in Magento2?

I need to override processMediaGallery method from \vendor\magento\module-catalog\Model\ProductRepository.php I used below code in my custom module etc/di.xml. < preference for="\Magento\...
4
votes
1answer
250 views

One to many relationship in M2

I am working on a module where I have to implement one to many relationship. I have one table for series with id and name field and one table series_product where I have id, series_id, product_id and ...
2
votes
4answers
777 views

Get quote item collection by using quote item id in Magento 2

I get the quote_item_id like this: $orderItems = $order->getAllItems(); foreach($orderItems as $orderItem){ $qouteItemId = $orderItem->getQuoteItemId(); } I need to load quote item ...
3
votes
3answers
292 views

Magento 2 addFieldToFilter equal today for datetime field

I have a model with field in datetime format, i want to filter the field with equal today date like this: $collections = $this->customFactory->create()->getCollection() ->...
0
votes
0answers
30 views

Model for sales_flat_order_payment table

I want to fetch the data from sales_flat_order_payment table and display in my admin panel grid. Is there any model through which I can fetch the data? If not, what is the work around to fetch the ...
0
votes
0answers
15 views

Total number of transaction not equal to total number of orders

I fetched all the transaction details using modelclass: sales/order_payment_transaction but my number of transactions are not close to Magento orders. What can be the problem or am I fetching it using ...
1
vote
1answer
31 views

Magento 2 : injecting models, interfaces in constructor magento

I'm new to magento 2 and I'm trying to understand how exactly injections work in magento. I understand that injecting a model and interfaces is the right approach in magento 2. But for some reason ...
2
votes
1answer
262 views

Column value display wrong when export CSV in magento 2 admin UI component grid in magento 2

In my custom module admin UI component data grid there is a one column is named "Status" all data display perfectly. But my problem is when i export data then "Status" column value display 0 OR 1 ...
6
votes
1answer
384 views

I want to add my custom entity for export Magento 2

I want to export my custom entity from the admin like products, customers, etc... I have already created the code for the import for my custom entity and it is working fine. But now I want to add the ...
1
vote
1answer
26 views

Change to Production mode the Theme something error

Change to Production mode the Theme something error but developer mode is working , how can i do? please help! thank you! my command: php bin/magento deploy:mode:set production -s --skip-compilation ...
2
votes
1answer
123 views

I want to override model in the Magento 2

I want to override the Magento\Catalog\Model\Layer\Category\FilterableAttributeList model file. I have created the module. This is my di.xml file. <config xmlns:xsi="http://www.w3.org/2001/...
0
votes
0answers
82 views

Magento 2.2.3 CommonTaxCollector Model override not working

I want to override mapItem function which is under CommonTaxCollector model class. I have done these steps : app/code/[VendorName]/[ModuleName]/etc/di.xml <?xml version="1.0"?> <...
1
vote
0answers
24 views

Magento 2 plugin not working for CommonTaxCollector model

I want to overwrite mapItem function which is under the CommonTaxCollector class. So, I have done this but getting undefined error. Uncaught Error: Call to undefined method Magento\Tax\Api\Data\...
0
votes
2answers
44 views

Run magento extension model inside php script

I have a custom extension model like this: app/code/Namespace/Module/Model/Core.php <?php namespace Namespace\Module\Model; class Core { public function save($data){ .... } } I want to ...
2
votes
1answer
79 views

How to use _redirect() method in Magento 2 model file

Magento\Framework\App\Action Redirect method is defined in Magento controller interface /** * @var \Magento\Framework\App\Response\RedirectInterface */ protected $_redirect; So i am aware about ...
0
votes
1answer
264 views

Get Category with a custom attribute programmatically [closed]

How can I load a category with only the value of a custom attribute in a controller?
1
vote
2answers
76 views

how to get post data in Magento Model File - Magento 2x

I want to get POST data in Model file, Which is my custom file of AccountManagement /app/code/[Vendor]/[Module]/Model/AccountManagement.php Note: I can access it through $_POST, 'superglobal' ...