Questions tagged [collection]

Questions related to Magento collections

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

How to write sub-query with group by in Magento 1.9?

I am new in learning Magento. I need to create query like this, SELECT * FROM YourTable WHERE ARIDNR IN ( SELECT ARIDNR FROM YourTable GROUP BY ARIDNR HAVING COUNT(*) > 1 ) How to write this ...
0
votes
1answer
145 views

Magento 2 Category Collection doesn't show items not in Top Menu

I am trying to display certain categories along with their images on homepage. I've made sure the categories dont appear in the top menu and only in the code that I am trying to use. Below code only ...
1
vote
2answers
28 views

Simple type products collection - wrong count

Here's a collection that should include all simple products in my magento store: $collectionSimple = Mage::getModel('catalog/product')->getCollection() ->addAttributeToFilter('...
1
vote
2answers
513 views

Collection filter date range not working

I tried to find the collection that has a range created between 4 hours, but somehow it doesnt show the right collection size, it always returns '0', here's how i use the filter: $to = date('Y-m-d H:...
4
votes
0answers
87 views

How to handle multiple tables with magento 2 repositories?

As we all know, magento 2 suggests using repositories as an additional layer between resource models/collections and the rest of application. It's all pretty straightforward and simple when you use it ...
0
votes
1answer
592 views

Magento 2: Sort multilevel category collection by both level and position

I am using Magento 2.2 and I want to get a collection of categories that is made up of a number of sublevels of a specific category. How can I get this collection sorted by both level and position so ...
1
vote
2answers
310 views

Magento 2: How to get a customer by Telephone attribute?

I'd like to filter my collection using something like: $collection->setField('telephone') ->setConditionType('eq') ->setValue('(555) 229-3326') But the telephone attribute is an ...
0
votes
1answer
35 views

getCitiesAsOptions() [closed]

I try to get from collection, City ID and City Name, to put in module Meanbee/Shippingrules as new condition All it's good but on multtiple select filed I get city iD-s, I supose to get name as Label ...
4
votes
0answers
148 views

Magento API complex filter value from another key value

I have a custom soap api for my magento 1 website, the problem is i dont know what array value to pass as the filters parameter so the parameter will work like this: $collections = Mage::getModel('...
0
votes
2answers
545 views

How to get All Active Categories in Custom Module Admin Form(UI-component) Dropdown in Magento 2?

I need to get all categories in a dropdown in admin ui form. So Please provide me a solution Form.xml <field name="category_name" sortOrder="10" formElement="select"> <argument ...
0
votes
1answer
790 views

Magento 2: Merge multiple collections

For a configurable product I want to get all related products of the linked simple products. How is it possible to merge multiple collections? At the moment I overwrite the related products on each ...
1
vote
1answer
240 views

How to load filter state for admin grid?

I'm looking for a way to get the state/settings for the order_sales_view grid on a in a php class. I want to load the grid and the filter state to use for selecting previous and next order according ...
1
vote
2answers
627 views

How to add filter to the collection of attributes in magento 2

magento 1 code to get all the attributes collection public function getAttributes() { $collection = Mage::getResourceModel('catalog/product_attribute_collection')->addVisibleFilter()-&...
0
votes
1answer
352 views

How to get all the attributes and show in the dropdown field in a backend form in magento 2

I have created backend form which has one dropdown field. How Do I get all the attributes and show it in a dropdown in magento 2
0
votes
4answers
866 views

Magento 2, preference for Magento\CatalogSearch\Model\ResourceModel\Fulltext\Collection does not work

When filters + Ancor is enabled for category, sorting by product name doesn't work. I know the fix as I tested in Magento\CatalogSearch\Model\ResourceModel\Fulltext\Collection. So now I'm trying to ...
1
vote
1answer
752 views

Magento 2 product collection not filtering by custom attribute (Type multi-select)?

I am trying to filter product collection with custom attribute "Groups" code "group" which is a multi-select attribute created from Magento admin, but it is giving empty result (this attribute is ...
0
votes
1answer
31 views

Multiselct product attribute is not beign added into collection filtering

I have created a multi select attribute and assigned this to attribute set. Attribute is showing in product search results but I am unable to include this into product collection filtering as well as ...
0
votes
1answer
207 views

Get admin grid's row count Magento 1.9

If I am creating a block which is type 'Mage_Adminhtml_Block_Widget_Grid' in my controller like so... $block = $this->getLayout()->createBlock('mymod/adminhtml_mymod_my_grid'); I can get the ...
1
vote
3answers
368 views

count is not working after filtering the collection

I am getting the correct count using code. $this->getCatalogRuleCollection()->count() But when I am adding the filter to it is not working. Following code is not working. $this->...
2
votes
3answers
2k views

Magento 2 filtering product collection and sorting

Considering below I can display products with true value of my custom attribute in ascending order based on position. How can I have products with false right after these in ascending too? if ($...
0
votes
2answers
1k views

Magento 2 : How to filter customer group collection?

Anybody have idea about how can i filter customer group pragmatically ? I can able to get customer group collection by using below code. $customerGroupsCollection = $objectManager->create('\...
3
votes
2answers
681 views

how to get status of last order id in magento2 sql query?

i want to get last order id along with order status in magneto2, i use this query to extract it but the status is not extracting correct: SELECT max(entity_id) , STATUS FROM sales_order max ...
1
vote
2answers
1k views

Custom column in Magento 1.9 admin grid

I am creating a custom grid in an admin module. This grid represents a table almost column for column, however, I want to add a completely custom column with a bit of logic to this column. Here's my (...
1
vote
1answer
615 views

Add custom 'select' statement to Collection Magento 1.9

I am working with custom grid. I have a literal value I need to pass to _prepareColumns(). Rather than setting up a custom renderer, I want to just add the literal value to the main collection. In ...
1
vote
2answers
477 views

Update product weight in Magento 1.9.x script

I'm writing a script to update product weight programmatically in magento 1.9.x. The file contains more than ~50000 When I start script the execution time for 100 records is 20 seconds, then the ...
0
votes
3answers
1k views

IN STOCK FILTER FOR Magento 2 Product collection

i am trying to filter inStock product in Magento 2 Using \Magento\Catalog\Model\ResourceModel\Product\CollectionFactory $collectionFactory, by $collection = $this->_collectionFactory->...
1
vote
0answers
44 views

Getting products in a category not under the current store's root

I would like to loop through a set of categories which are under a separate root, in order to generate a simple list of products. I put them under a separate root category because otherwise they end ...
1
vote
1answer
100 views

Only including products in a collection based on their category sort position

When building a product collection, is there a way to only include products with a category sort position greater/less/is than (x)? I've tried searching but couldn't find a case of where anyone had ...
1
vote
1answer
649 views

How to Add Product to Wishlist Programmatically Using Object Manager in Magento2

I have existing product slider and that slider made with object manager so I want to add the product to wishlist by Product id Using Object Manager.
0
votes
1answer
24 views

How to get all cms blocks ids where “is_slider” = true?

Modyfying current slider system to make it a little bit more autonomous as in it's original form I must manually remove code from list if specific products is already gone or promotion is over so I ...
0
votes
4answers
5k views

Magento2: Get category product count which is show in admin after the category name

I want to show category product count which is shown in admin after the category name. As of now I write this code but it's not working properly. $category->getProductCollection()->count(); ...
0
votes
2answers
837 views

Filter Custom Grid Collection

I am trying to filter my collection from my custom table using _initSelect method in class Collection in namespace Anshu\Custom\Model\ResourceModel\MyData protected function _initSelect() { ...
0
votes
1answer
291 views

How to check if a column filter already applied into collection

I want to check if a column entity_id filter already applied into collection. For eg: Product collection has already applied entity_id filter where entity_id in (1,2,3) etc. So i want to check ...
0
votes
1answer
1k views

How to get the upsell product Collection in list page in magento 2

I have created a module to show upsell products in List page. In List page, I have put one icon on each product, while clicking that icon, It would need to show upsell products list which is ...
1
vote
1answer
466 views

How to increase the paging limit in magento 1.9 REST API

I am using the following code to fetch category tree where almost i want to fetch around 1000 records but only getting 100 records because of limit. $resourceUrl = "$apiUrl/categories/store/default?...
0
votes
1answer
346 views

How to create static block to display banners in home page in magento 2

I have created admin grid and form using ui-component for adding banners. In frontend I have displayed the banners collection by hitting the controller path. Without controller path, how do I show ...
4
votes
1answer
3k views

difference between collection and collectionFactory

I need the list of all the admin users. And, both the below set of codes, provide the same result. Code 1 public function __construct( \Magento\User\Model\ResourceModel\User\Collection $...
2
votes
2answers
2k views

How to get datas from this table 'directory_currency_rate'

Table contains these columns. I need to get data from this table 'directory_currency_rate' which is come under this directory /vendor/magento/module-directory/Model/Currency.php /vendor/magento/...
0
votes
1answer
430 views

How to get collection of ids in desc order?

I'm trying to get a collection/list of subcategories in desc order. $subrategories = $brategory->getChildrenCategories() ->addAttributeToSelect('*') ->addAttributeToFilter('...
1
vote
1answer
2k views

Category order does not work, always sort by the entity_id desc

I have a problem with my categories, and I don´t know if this is normal or not. In Magento 2.2.2 I created a custom attribute, and added it for sorting attributes. But when I tried to order product ...
1
vote
0answers
98 views

Missing eav attribute options in collection

I miss some custom attribute options in my collection. I'm using the standard "\Mage_Catalog_Model_Product_Type_Grouped::getAssociatedProducts" method. When I debug the collection inside that method ...
0
votes
1answer
254 views

Clearing product collection in Product Listing without images - Magento 1.9

In our Magento project we have around 200 thousand skus and many of them are with incomplete information. So we made a filter to prevent products without images from appearing on the category pages. &...
1
vote
0answers
157 views

Problem in creating custom reports for inventory forecasting

I have followed this https://magento.stackexchange.com/a/14783/34850 & copied as it is & then made several changes like name space, grid(columns/field names) & query but somehow not ...
0
votes
0answers
216 views

convert sql query to magento collection

I am having a complex SQL query to make a custom report & showing same to custom report grid but somehow not able to convert the query into Magento's equivalent Collection. SELECT SUM(order_items....
1
vote
1answer
429 views

Magento2 does n't get the order collection from Order\CollectionFactory

I am using the Magento2.2 version . I am using the class Magento\Sales\Model\ResourceModel\Order\CollectionFactory; to get the order collection.But getting the error Fatal error: Uncaught Error: ...
1
vote
2answers
974 views

Magento 2 get list of the guest orders

I want to show list of the guest user in my custom module. Which is the best way to get the list of the guest order. How can i get list of the guest orders? $objectManager = \Magento\Framework\...
1
vote
1answer
86 views

Collection Sort Order in Text Field - Same values are ordered randomly

I am sorting a custom collection by a text field EAV attribute (UMC was originally used to scaffold the module which has been heavily modified since). $myCollection->setOrder('my_name', 'ASC') ...
3
votes
2answers
623 views

How can I get collection result “column headers” or “column names” in Magento 1.9x?

How can I get collection result "column headers" or "column names" from query? Suppose I have $data = Mage::getModel('catalog/product')->getCollection(); and I have some joins with other tables I ...
1
vote
3answers
4k views

Magento2: load attribute using attribute code

I am using the below code to load the attribute using attribute code but it's not working:- protected $_attribute; public function __construct( ... \Magento\Eav\Model\ResourceModel\Entity\...
0
votes
1answer
674 views

Clean way to add media gallery images to product collection

I have to display small images of products loaded by collection. Problem is (I think it is), that products (coming from collection) by default doesn't containt any images within. I have tried ...