Questions tagged [collection]

Questions related to Magento collections

5
votes
0answers
1k views

Magento 2 : How to generate a collection from data models

If I understand correctly, Magento 2 moves more and more to the strict use of data models instead of creating models that are tied-in with their resource models and have all kind of business logic ...
4
votes
0answers
140 views

Magento 2 addProductsFilter to Stock Item collection

In Magento 1 you were able to add a product filter to a Stock Item collection in the Mage_CatalogInventory_Model_Resource_Stock_Item_Collection class. This functionality appears to be missing along ...
3
votes
0answers
159 views

Order Collection based on Multiple Select Option Values Magento2

I have a list of products (books) with a custom eav multiple select attribute named 'authors' in magento 2. This attribute is 'visible_on_front' and also 'used_for_sort_by'. I am trying to use that ...
3
votes
0answers
179 views

loop through 2 collections with in one phtml

I am working on a custom module that is pulling in 2 different collections. When I try to use a foreach to loop through either of the collections the page displays the collection correctly. However, ...
3
votes
0answers
75 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 ...
3
votes
0answers
105 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('...
3
votes
0answers
48 views

Magento 2 : How to get top 10 repeated values in a column using CRUD instead of sql?

I want to get top 10 most repeated values in a column of my table, I can do so using sql but I need to do it using CRUD i.e using collections or model as magento coding standard doesn't allow naked ...
3
votes
0answers
283 views

Magento 2 : How to Return the Collection from afterload

I have implemented this jquerytokenizer in Ui Component form shown in the below image. It works well , the data is saved accurately- but when I go to edit a saved record this field is empty ...
3
votes
0answers
394 views

Magento 2: products collection with multi-selected values of multiple attributes

I have numbers of custom attributes with multiple selected values in magento catalog. I need to filter products by multiple attributes having multiple selected values. eg: Attribute set having a ...
2
votes
0answers
46 views

how to do pagination to display collection at admin panel custom table in magento 2

I'm trying to create a pagination for my collection to display in a .phtml file, but am getting error page Invalid template file: 'Magento_Theme::html/pager.phtml. Here is my code: code/...
2
votes
0answers
32 views

how to use filters for new collection

I use in my decision the answer that was in this question Magento 2 Custom Collection Everything works fine, but how to filter data when they are searched? My code $collection = $this->...
2
votes
0answers
44 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 ...
2
votes
0answers
344 views

Magento 2 : collection filter error : Exception #0 (RuntimeException): Illegal state

I am having problem with collection filter I am using event catalog_product_collection_apply_limitations_after to add collection limitations In the observer i am using below code to apply filter. ...
2
votes
0answers
197 views

Magento 2: Filter by custom product/category attribute returns 0 results

I created a bool (int) attribute with a default value of 0 for both category & product entities. I reindexed, cleared cache, etc... Now, no matter what I do, I can't filter the collection using ...
2
votes
0answers
216 views

Create filter group inside foreach dynamic filters

I'm following this link to create a filter group to be applied to my custom collection. searchCriteria => [ 'filterGroups' => [ 0 => [ 'filters' => [ 0 => [ ...
2
votes
0answers
826 views

Magento 2 filter not working on custom column

Magento 2 Filter is not working. In the below code column created through layout xml are getting filter, but on column created via column class file filter is not working. I have found that one ...
2
votes
0answers
222 views

Join table to get the detail of customer, customer ordered item, and the item product

i'm following this tutorial to create the grid for custom report, and to get the collection there's a function which accept the from date and to date like this: public function setDateRange($from, $...
2
votes
0answers
61 views

Magento2 Custom Module Backend - Pass ID FK from GridView Master to GridView Details

I have to pass a FK parameter from GridView Master to GridView Details. GridView Master (GVM): GridView Details (GVD): PROBLEM: After click on 'Questions' on GVM for ID = 22, in GVD is showed all ...
2
votes
0answers
196 views

convert direct sql to collection in magento 2

How we can convert direct SQL query to collection ? SELECT wk_mpauction_winner_data.auction_id, wk_mpauction_winner_data.customer_id, quote_item.created_at AS quote_item_date ,sales_order_item....
2
votes
0answers
585 views

Layered Navigation on Custom Product Collection Page

I am developing module "Shop By Brand". So on the Brand details page it's displaying Brand details with Product Collection related to brand. All things are working except "Layered" navigation. I have ...
2
votes
0answers
209 views

Pre filter datasource for Magento 2 custom grid

I have 2 grid that i want to use in my custom module, the first grid have actions column that have link to access the second grid, the problem is i want to load data in second grid (listingproduct) ...
2
votes
0answers
356 views

Magento 2 How to filter shared wishlist items function?

I want to add a new filter in shared wishlist items. I have used the preference method to override the block method. The problem is that the addFieldToFilter is not working. How can I achieve it? ...
2
votes
0answers
96 views

Change the sitemap.xml size limit in magento 1.x.x

It seems that Magento 1.x.x. generated sitemap.xml is limited to 10MB. Is there any way to change the limit? I do know that I'll need to split the generated sitemap into smaller chunks after that to ...
2
votes
0answers
93 views

Filter collection in listing Magento 2

I want to add in layered navigation filter by stock. Example: filter by Product in stock Product out of stock Which block or model i must to rewrite?
2
votes
0answers
2k views

Magento 2: Duplicate key-sequence unique identity-constraint 'uniqueVirtualType' fatal error while di:compile

When i run php bin/magento setup:di:compile it gives me below error [Magento\Framework\Exception\LocalizedException] Invalid Document Element 'virtualType': Duplicate key-sequence ['Custom\...
2
votes
0answers
43 views

Media image cron upload is failing to upload any images to my simple products

Front image should only load for configs and this works fine. Simples should load front and back and all other angles. It looks for F (front) and B (back), sets those to 1 or 2, everything else is ...
2
votes
0answers
32 views

Move all native magento reviews from my default store 0 to my new store

My script currently works for all stores except the store it's pulling from. I want to pull all reviews from my default store / main store and only push the reviews to my new store with a websiteId = ...
2
votes
0answers
114 views

Trouble fetching current product collection for category without limit

Within my templates category list.phtml I need to pull the full product collection without the page limit. To be clear I do not want to impact the toolbar, pagination, or anything else within category ...
2
votes
0answers
173 views

Excluding products from layered nav filters

In my product collection on category list pages I am filtering to exclude products with certain attribute sets: return $this->_productCollection->addAttributeToFilter('attribute_set_id',array ('...
1
vote
0answers
22 views

Magento 2 : Need to set custom category collection using plugin

I want to set custom category collection using plugin. I created plugin about Magento\Catalog\Block\Product\ProductList\Toolbar this block and aroundSetCollection(). But, not actual output I received....
1
vote
0answers
19 views

how to use walk method to join two tables in magento 2

friends, how to use the walk() method to join two tables in Magento 2 I have 2 tables and I want to join them based on some conditioning. my present code looks like this $result = array(); $...
1
vote
0answers
34 views

Autocomplete with ul li input in Magento2.2.5?

I want to show the value in autocomplete. Refer my code below: <script src="http://code.jquery.com/ui/1.10.2/jquery-ui.js" ></script> <script> <?php $zipdata = array(); ...
1
vote
0answers
28 views

Attribute set sort order has gone - how to rebuild?

This code returned attributes set for dropdown menu - ordered by attribute set name ... $sets = Mage::getResourceModel('eav/entity_attribute_set_collection') ->setEntityTypeFilter(Mage::...
1
vote
0answers
59 views

How to redirect to 403 custom error page in magento2 from controller

I am trying to redirect to custom 403 error page. I have created plugin for controller as follow: etc\di.xml <?xml version="1.0"?> <config xmlns:xsi="http://www.w3.org/2001/XMLSchema-...
1
vote
0answers
63 views

How FIlter Order Items Collection?

How Filter(make custom array) Order Items Collection when view order from front end admin page sales order grid.
1
vote
0answers
37 views

Magento 2 searchCriteriaBuilder for multiple collection

I want to create search functionality for customer to search his invoice order etc. For this I'm using searchCriteriaBuilder and \Magento\Framework\Api\SearchCriteria\CollectionProcessorInterface ...
1
vote
0answers
32 views

Magento 2: Sub category showing product from other sub category

I have a block class that extends \Magento\Catalog\Block\Product\ListProduct and tried to override the list.phtml with exactly the same file (say mylist.phtml), except it is located under my module. ...
1
vote
0answers
205 views

How to sort a collection after load

I have a store collection. And it has the following fields [0] => Array ( [location_id] => 5 [title] => Los Angeles [description] => [status] => 1 ...
1
vote
0answers
51 views

How to get collection from database in phtml not from cache when full cache enabled

I have created an extension which I have uploaded in the marketplace but marketplace rejected due to cacheable="false". <block class="Company\Module\Block\Hello" name="information" template="...
1
vote
0answers
155 views

override getLoadedProductCollection of \Magento\Catalog\Block\Product\ListProduct

I am overriding getLoadedProductCollection() in my block where performing some custom query public function getLoadedProductCollection() { $myCategory = $this->...
1
vote
0answers
106 views

Set the default id of items in a custom collection

What I have I've created a grid in admin area which fills with this collection: protected function _prepareCollection() { $collection = Mage::getResourceModel('mymodule/mymodel_collection') ...
1
vote
0answers
138 views

Pagination not working in custom grid collection

I have created the grid with custom collection filter grid displayed proper but pagination not working. Any have an idea about the same. Please find below my code <?php namespace Abc\Xyz\Block\...
1
vote
0answers
84 views

Filtering grid by using filter_url_params is not working

I added a grid to a ui_component form and I want to use an Url-parameter to filter the content of the grid. Herefore I added the 'filter_url_params' in my listing: <dataSource name="...
1
vote
0answers
229 views

Magento 1: $productCollection->getData() vs foreach ($productCollection as $product)

I have Magento product collection with some filters. when i call $productCollection->getData() I have right result, but foreach($productCollection as $product) gives wrong products. why its ...
1
vote
0answers
347 views

Magento 2 : Get Customer Collection with it's Attribute

I've managed to get customer collection using class \Magento\Customer\Model\ResourceModel\Customer\CollectionFactory but it returns me default details not with Created Customer Attributes. Any ...
1
vote
0answers
41 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
0answers
87 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 ...
1
vote
0answers
130 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 ...
1
vote
0answers
362 views

How to Filter Attribute Set, Attribute option value and filter by manufacture in product export

Change into app/code/local/Mage/ImportExport/Model/Export/Entity/Product.php on line 647 in funtion export() $collection = $this->_prepareEntityCollection(Mage::getResourceModel('catalog/...
1
vote
0answers
156 views

Incorrect product count in layered navigation filter while sort using custom collection

I have an issue with layered navigation filter count. I have changed the product collection of sort, everything is working fine except the product count. Can anyone help. Toolbar.php class ...