Questions tagged [collection]

Questions related to Magento collections

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

Product by category id in magento [duplicate]

how we can get product by category from collection
0
votes
1answer
397 views

Filter in grid not working with Varien_Data_Collection

I have created custom collection with Varien_Data_Collection in admin grid like below : protected function _prepareCollection() { $collection = Mage::getModel("catalog/product")->getCollection(...
0
votes
0answers
116 views

Magento 2 not able to get creditmemo collection

I am trying to get credit memo collection with following script but am unable to get the collection class Creditmemosync extends \Magento\Framework\App\Action\Action { protected $helper; protected $...
0
votes
1answer
678 views

How i can join eav_attribute_option_value table into my collection and get from him “frontend_label” of colors?

I have a products collections. But in "color" i see option_id number. Mage::getModel('catalog/product') ->getCollection() ->addStoreFilter(Mage::app()->...
0
votes
1answer
95 views

How to export a specific order in Magento 1

I created a button to export a specific order from admin. This button apper on each order. Then i created a function that look like this: public function expButtonAction() { Mage::app('...
0
votes
1answer
448 views

Magento 2 - For custom table collection object, getIdFieldName() is returning null

Custom table created with name 'picklist_item' with 'item_id' column as primary key, in one of the admin controller action, collection object for 'picklist' table has been created and called ...
0
votes
0answers
29 views

Error when adding multiselect attribute

I am trying to add a multi select attribute with a collection ( custom created ) , the attribute has been added successfully but when I edit collection to fill this new field value it shows an error ...
0
votes
1answer
1k views

Magento 2 get custom module data in theme phtml

I have created the custom module and inserted all the required fields detail in the database. Now, I want to list all rows in below file path: I have tried with the $objectManager, but direct call $...
0
votes
0answers
298 views

How to add , another model collection data to an array. : magento 1.9

I have response collection $customerData, i have to add referral code of selected customers in the same array, model and field of referral code is : $referCustomer = Mage::getModel('...
0
votes
1answer
336 views

Sorting Collection after joinField not working

I have a collection of products which I filter and show out of stock items only and it works fine. This is what I have: $collection = Mage::getResourceModel('reports/product_collection') ->...
0
votes
1answer
847 views

process collection after load collection

$categoryid = 43; $layer = Mage::getModel("catalog/layer"); $category = Mage::getModel("catalog/category")->load($categoryid); $layer->setCurrentCategory($category); $attributes = $layer ...
0
votes
0answers
121 views

How to Dispatch catalog_product_collection_load_after zero products in Magento 2.1?

I noticed that in Magento 2.1 the event catalog_product_collection_load_after is dispatched only when the collection has at least one product. How can I make Magento dispatch it also when the ...
0
votes
1answer
353 views

Load all record when reset collection for magento admin form grid

I have grid which have collection if i choose to reset it gives only joined or mapped record so when i select reset button on grid it should be display all record without filtering. My code is as ...
0
votes
1answer
198 views

Magento 1.9 - Modify CMS pages that are available in one store and aren't available in another

I'm looking for for a way to modify CMS pages that are available in one store and aren't available in another store. First problem is that I cannot filter cms pages the usual way: $collection = Mage:...
0
votes
1answer
371 views

how to force collection to include attribute value in select?

This code Mage::getResourceModel('customer/customer_collection') ->addAttributeToSelect('username', 'password_hash') ->addFieldToFilter('username', 'name')->getSelect()->...
0
votes
1answer
53 views

How do I add an attribute + it's sortorder (position) to the product list collection?

How do I add an attribute + it's sortorder (position) to the product list collection? In the catalog category list we use 1 text attribute (brand) and 1 list attribute (size) .... for every product ...
0
votes
2answers
645 views

filter product collection when flat product and category in ON

I've enabled flat tables. Now the new arrival products aren't appearing which is filtered by a particular category. Below code works when flat tables are disabled. $cat = Mage::registry('...
0
votes
1answer
57 views

Get multiple element in join on sql request into collection

I have a table "test_brand" and a table "test_vehicles". In "test_vehicles" I put a parameter which is "brand_id". Now I want to get in my template a collection with all brand and for each brand all ...
0
votes
0answers
225 views

Grid Page for custom collection in Front end

We have a marketplace website, where we have list of vendors. In a page, we need to list all vendors for customers, So that customers can search and filter by Vendor's group, name, location. It ...
0
votes
1answer
44 views

Magento collection bug

I am a newbie and am trying to get a collection working. I read a lot, tried many things and had no luck. This is a very basic need. I am trying to add a column sap_increment_id on my sales order ...
0
votes
1answer
1k views

Load collection in foreach() is already flagged as loaded

In a custom module UpgradeSchema, I've this constructor : function __construct( AttributeManagementInterfaceFactory $attributeManagementFactory, ) { $this->attributeManagementFactory = $...
0
votes
1answer
280 views

Display three products in one category

What is the code to do it he can see three products in one category only?? <?php $category = Mage::getModel('catalog/category')->load(68); $product->addCategoryFilter($category); $...
0
votes
0answers
125 views

Magento 2: Update Multiple Tables At Once

In Continue with Magento 2: How many tables required to change Order Status Programmatically? I have below code $orderIds = array(); $objectManager = \Magento\Framework\App\ObjectManager::...
0
votes
1answer
62 views

Magento 2: Guide for All Collections

For now, I'm not able to find any guide for this. If I need to get all collection say for Example all Orders List so I will go to Vendor Magento Folder, Particular Module's di.xml file & checking ...
0
votes
2answers
392 views

Product filter by category not working

I have three categories like CAT-A, CAT-B, CAT-C and I want the product collection from these by the order CAT-A products, CAT-B products, CAT-C products. When I trying to get the product collection ...
0
votes
0answers
79 views

Magento 2: Conver SQL Query to Magento Format

In addition of Magento 2 How to set group by in Collection query? I have below query now. SELECT t1.* FROM messages t1 WHERE t1.id = (select max(id) from messages t2 where t2.posts_id = t1.posts_id ...
0
votes
1answer
164 views

Foreach Loop Pulling Wrong Value From Collection

I have a foreach loop that I am running over a Magento collection so I can run pull in the info for multiple patients (it's a pharmacy). However, after each iteration of the foreach loop, it returns ...
0
votes
2answers
612 views

Magento 2 Custom Module Delete Issue [SOLVED]

I'm using Magento 2 Version 2.1.0 {folder path}\magento2\app\code\Custom\Module\view\adminhtml\ui_component\custom_module_index.xml <massaction name="listing_massaction"> <argument name=...
0
votes
1answer
760 views

Get product collection based on entity_id in magento2

How to Create product collection with filter based on entity_id in Magento 2? I tried below: $model = $this->_objectManager->create('Vendor\MOdule\Model\Queue'); $ProductId = $this->...
0
votes
0answers
52 views

Group products when showing recently sold items using sales/order_item

I can show the most recently sold items and sort them based on created_at using this: $itemsCollection = Mage::getModel('sales/order_item')->getCollection() ->setOrder('created_at', ...
0
votes
1answer
849 views

how to store custom collection in cache in admin grid?

My collection model is testimonial/record. In database table(testimonial_record) 2,00,000 records so it loads more how to decrease time to fetch collection data in grid.So I think I have to store ...
0
votes
0answers
554 views

Get CatalogInventory stock collection in Observer

I need, on website save, get the inventory with the current website ID. Ad I'm trying to get the CatalogInventory Stock Collection in an Observer, but it finish with the error: Configuration array ...
0
votes
1answer
457 views

Magento 2 : Can not add method/class in __construct()

I have a collection.php file. I am adding some function into that which calls other models.As per Magento 2 first we have to add object managerger interface. And then we can call other model.like ...
0
votes
1answer
425 views

How to get a collection of Out Of Stock (including configurable) products

In my magento i have "Display out of stock products" -> No. (i needed like this). I want to create a page with all out of stock products. I have everything working, but cannot find the correct ...
0
votes
1answer
71 views

How to add an often used attribute to the collection loaded on category page, related products, cart page etc

If you have a custom attribute that you use everywhere, on category page, on product page, in related items, on cart page, on checkout etc., how do you add it to the collection that gets loaded by ...
0
votes
1answer
161 views

Magento rewrite Mage_Adminhtml_Block_Catalog_Product_Grid

I'm doing a rewrite of: Mage_Adminhtml_Block_Catalog_Product_Grid I already done most of the job on my custom module. The function getStoreRestrictions() returns an array of all available stores view ...
0
votes
1answer
258 views

how to use other module collection in another module

I have a 2 Module marketplace and followup i want to use followup collection in marketplace module i want to send mail after save product marketpalce Module public function newpostAction() { ...
0
votes
1answer
403 views

Magento - Add custom table data into Products collection [duplicate]

I have created a custom table which stores the listId (you can think of it sort of wish list) and product id and created Model and Model resources. What I need is the actual product data based on the ...
0
votes
1answer
898 views

Getting Notice Notice: Use of undefined constant sales_flat_order_status_history - assumed 'sales_flat_order_status_history'

I have created below collection query in my custom external magento page-- <?php $mageFilename = 'app/Mage.php'; require_once $mageFilename; Mage::setIsDeveloperMode(true); ini_set("...
0
votes
1answer
93 views

Magento Custom Collection breaks Admin grid

I do have following code below for a Grid in Admin protected function _prepareCollection() { $pimage_collection = new Varien_Data_Collection(); $pimage_array = array(); $...
0
votes
1answer
206 views

addAttributeToSort with MySQL “IN”

I want to sort a catalog_product_collection by multiple attributes but with special input. As I understand the method addAttributeToSort calling it like this addAttributeToSort("attribute"); Seems ...
0
votes
1answer
225 views

Product collection based on the total sales of a product within a period

What I need is the logic for creating a product collection based on the total sales of a product within a period. So if a product costs 10 $ and I sold 540 I want the sorting to be based on the total ...
0
votes
2answers
524 views

Get product id only from load order condition

I am working on order collection module. I want only product id after load particular order. This is my query, $ordered_items = Mage::getModel('sales/order')->loadByIncrementId($incrment_id); Is ...
0
votes
1answer
688 views

filter a product collection by attribute and tag

How can I filter a collection by both an attribute and by a tag? I can filter a product collection by doing: Mage::app()->setCurrentStore( $storeId ); $collection = Mage::getModel( 'catalog/...
0
votes
1answer
490 views

Magento 1.9 addAttributeToFilter: compare as numbers instead of strings

I have created an own product-attribute "height" in magento-backend. The input type is "text" (because there was no similar type like "float"). To use this attribute as a filter I wrote a small ...
0
votes
1answer
127 views

EAV collection problem with Customer entity

(Magento CE V1.7.0.2) I have a problem with the customer data collection, I can't have any "telephone" number. I must remove the line ->joinAttribute('billing_telephone', 'customer_address/...
0
votes
1answer
86 views

product collection of arbitrary skus

I was wonder if there is any extension available that would let me create filterable product collections where the collection is built by sku fro the url. So the url would be something like: /...
0
votes
1answer
1k views

get quantity of enabled and disabled products by sku

I am handed a list of skus from a black box. I need to return a collection containing the quantities of all skus within the array. function fun1($arrayOfSkus){ ..... $collection = Mage::...
0
votes
1answer
358 views

Merge custom collection into customer/address collection

I'm making an extension, that lets the user define companies and add addresses to them. The plan is to show those addresses to the customer according to the value of an attribute in the customer (eg. ...