Questions tagged [getmodel]

The tag has no usage guidance.

Filter by
Sorted by
Tagged with
2
votes
2answers
48 views

I want to exclude empty category from Mage::getModel in Magento 1.9

$allCats = Mage::getModel('catalog/category')->getCollection() ->addAttributeToSelect('*') ->addAttributeToFilter('is_active','1') ->addAttributeToFilter('include_in_menu','1') ->...
1
vote
2answers
1k views

Magento 2 : Retreiving Data From Database, Use it in Knockout UI Component in Checkout

I have been developing a module for Magento2 Checkout that fills some information, not important what, this data resides in Magento's db, and I am able to access it via Magento database access layer. ...
1
vote
2answers
41 views

Can´t write in ddbb from form

I make a new module which is a simply form, but i can not write into the ddbb, because (i think) can not find the model. I have this code in controllers/IndexController.php: public function ...
2
votes
1answer
232 views

Get data from database using Magento Models

I have some sql queries and I need to get the same data returned by those queries, using Magento models. Since I'm very new to Magento, I don't know how to do this. Following are the sql queries. ...
1
vote
0answers
288 views

getOrder() doesn't return Mage_Sales_Model_Order when debugging

I try to var_dump($order) but it gives me : object(Varien_Object)#290 (7) { ["_data":protected]=> array(0) { } ["_hasDataChanges":protected]=> bool(false) ["_origData":protected]=> NULL ["...
1
vote
1answer
320 views

Magento: Which is optimized way to get single record? [duplicate]

load by Id $data = Mage::getModel('module_name/model)->load($id); or //collection by filter $data = Mage::getModel('module_name/model)->getCollection()->addFieldToFilter('id',$id);
1
vote
3answers
502 views

Can't get class of model - Maybe cache problem?

I'm following a video tutorial on Magento for developers and I'm quite a beginner at this. I'm currently using Magento CE 1.9.2.4. I created a simple dummy module which controller works fine. ...
1
vote
2answers
941 views

How to reduce use of Mage::getModel('catalog/category')

I'M NEW TO MAGENTO. IN FILE 1. $_category = Mage::getModel('catalog/category')->load($_category->getId()) $categories = Mage::getModel('catalog/category') ->...
0
votes
2answers
936 views

How to get the ID of a store by name?

Let´s say I have a store named "Megastore". How can I get the id of that specific store? Can I do it by using some kind of filter? Mage::getModel('core/store')->addFieldToFilter('name', '...
2
votes
1answer
1k views

Custom module model getCollection gives error

I have created a custom admin module and necessary assets. When I call getCollection using created model its giving me error Warning: include(Company\Module\Model\Resource\Event\Collection.php): ...
2
votes
2answers
840 views

How to include the module name in magento2

Is anyone knows how to load the model in magento2? What we need to do in magento2 to translate the below line in Magento2 $order = $observer->getEvent()->getOrder(); $orders = Mage::...
1
vote
3answers
3k views

Failed to open stream

I am just learning Magento from the book Magento for PHP Devs but when I tried to recreate this code I got an error: PHP warning: include(Mage/Mdg/Giftregistry/Model/Entity.php): failed to open ...
2
votes
1answer
1k views

Get customer by Tax/VAT number

I am looking to something similar to this one (thats works with email), But instead of get the customer by email, i want to get him by the Tax/VAT number. $customer = Mage::getModel('customer/...
2
votes
0answers
50 views

Set customer details at checkout [closed]

I'm currently working on a tool that will be used to add some parts to the checkout page. I have been looking at the core files but so far I haven't found anything about how to actually pre-set ...
6
votes
2answers
14k views

How do I get data from my custom module table?

I have a custom module with its own table which saves the date inside the column named date_to. I am trying to access the values from only this column but when I load the collection and call getData('...
12
votes
2answers
538 views

getConfig function run time

I measured run time for my page and noticed that the function getBaseCurrencyCode() takes over a second to run. All of my caching are enabled. I examined the function and saw that the following ...
0
votes
1answer
869 views

Filtering Magento product collection by multiple categories using AND condition

I trying to display a list of products in Magento based on multiple categories. I'm using the following code which works well: $collection = Mage::getModel('catalog/product')->getCollection() -&...
0
votes
1answer
27 views

is it better to retrieve a model once using aliases or doing that several times separately?

Is it better to use this :- $subcat= $_brands = $category = Mage::getModel('catalog/category'); or this :- $category = Mage::getModel('catalog/category'); $subcat = Mage::...
5
votes
2answers
5k views

Get all item-Ids from a Collection

I found out how to get the first item from a collection: $pageId = Mage::getModel('cms/page')->getCollection() ->addFieldToFilter('identifier', 'your name in the pages') -&...
2
votes
2answers
4k views

How do I call a model in a controller?

This is the content of my controller: <?php class Attin_Exportdb_Adminhtml_AttributesController extends Mage_Adminhtml_Controller_Action{ public function IndexAction() { $this->...