Stack Exchange Network

Stack Exchange network consists of 175 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

Questions tagged [collection]

Questions related to Magento collections

1
vote
2answers
42 views

Get all simple products of a category including not visible individually products - Magento 2

I need to get all simple products of a category. By using the following code, I'm getting only products which has visibility of Catalog, Search but not Not Visible Individually products. $categoryId =...
0
votes
1answer
39 views

Magento2: unable to get Actual result by using getSize()?

Collection protected function _getProductCollection() { $tagModel = $this->tagTagFactory->create(); $this->_productCollection = $this->_productCollection ->...
1
vote
0answers
32 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
1answer
22 views

Is there a way to select a field to be returned when using the getList() function within a Repository?

MAGENTO v2.2.6 To better illustrate my question here's an example. When using the ordinary collection I can limit the attributes/fields returned like so: NOTE: I wouldn't normally use the object ...
0
votes
0answers
291 views

Magento merge two collections with different sorting orders

I have one store in Magento 1.9 , There is a listing page with AJAX scroll loading, on first page I am showing 24 products. We are showing products with label In-Stock and Sold Out, In-stock products ...
1
vote
1answer
165 views

Magento 2 get special price product collection

I want to get all sale products (which have specila price and special from date and special to date) in a .phtml file. Which i use in any where in store.specially in list page.
1
vote
2answers
35 views

Removing a product from the collection on a category

I have a Magento site where I need to remove some products from certain customer groups due to them having a zero price on the products. I have tried catalog_product_collection_load_after event and ...
1
vote
0answers
27 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::...
0
votes
1answer
30 views

Could not filter product collection in Mage_Catalog_Block_Product_List by a custom attribute in magento 1.9

I have an issue similar to this question , and i checked the 'Already answered link' too. But my issue is bit different. The error is similar in the above link but with my custom attribute : ...
2
votes
1answer
28 views

Magento 1.x block data inheritance

I would like to know how does Magento blocks pass data to its child blocks. Example: <reference name="content"> <block type="catalog/product_list_toolbar" name="product_list_toolbar" ...
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->...
1
vote
1answer
30 views

Magento 2 - Display out of stock product for only one category while hiding them in all other category

How to display out of stock products only in one category with "Display Out Of Stock" option "No" in the admin?
1
vote
0answers
57 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-...
2
votes
1answer
401 views

Magento 2 : addAttributeToFilter, addAttributeToSelect, addFieldToFilter not working

I created eav entity module. But, when I use this addAttributeToFilter, addAttributeToSelect, addFieldToFilter function in my custom module collection. It's not working. My collection file : I ...
3
votes
0answers
147 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 ...
0
votes
1answer
35 views

Model Collection.php magento 2

I cant seem to find any information why we need to create a Collection.php file inside ResourceModel and what is the purpose of collection.
3
votes
2answers
180 views

Order Items Collection in Order Detail Page

This snapshot of order detail page. I Just want to known that which file or function call for setting this collection in this page. I want to just get Selected (Filter Row) Items Order.
1
vote
0answers
60 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.
2
votes
1answer
29 views

Order admin grid by values in another collection

I have a module, in this there is a field which contains the id from customer table. In my admin grid listing I show the name of the customer, not the id. When i short this grid by the field, the ...
1
vote
2answers
26 views

Getting Custom Collection without some fields

It is magento 1.9.4.0 and i need a array with some nodes. When i get the models collection with: Mage::getModel('nstok/nstok') ->getCollection() ...
1
vote
1answer
73 views

How to display only USA states as a select drop-down in custom phtml in Magento2.2.5?

I want to display only USA states as a select drop-down in custom phtml in Magento2.2.5? Any help would be appreciated.
2
votes
2answers
95 views

Magento2 filter not working for request parameter for order grid

I want to filter Sales Order query based on request parameter passed in querystring like following: http://127.0.0.1/website/admin/sales/order/index/key/...
1
vote
1answer
66 views

How to get 6 random product from a catregory in magento 2

I want to get 6 random product from same category on product page in magento 2
0
votes
2answers
30 views

How can I use mysql functions when I use collection filters?

How can I use something like this one NOW() - INTERVAL 10 DAY in collection filter? ->addFieldToFilter('period', ['gteq' => 'NOW() - INTERVAL 1 DAY']) Before running the query, the value in ...
1
vote
1answer
139 views

Collection not loading in Ui Component Admin Grid - stuck spinning

I have a basic CRUD repository setup, however when I try to go to the Admin Grid UI Component, the spinner just spins and nothing loads. No errors displayed in any of the logs either. When I inspect ...
0
votes
1answer
26 views

Magento2 add custom values in collection->setOrder

I need to add some custom values in setOrder() of a collection, but it is not working. $collection->setOrder("((lat - ".$lat.")*(lat - ".$lat.")) + ((lng - ".$lng.")*(lng - ".$lng."))", 'ASC'); ...
1
vote
2answers
140 views

Get products collection in cronjob

I have a cron file like Col.php. I want to get products collection in my cron file. code in my file: public function execute() { $objectManager = \Magento\Framework\App\ObjectManager::...
1
vote
1answer
25 views

Magento 1.9 : How to apply more than one price range on product collection

I want to apply multiple price ranges on final price of product collection. I have tried below code. $collection->addFinalPrice(); $collection->getSelect() ->where('price_index.final_price &...
3
votes
2answers
111 views

Search criteria builder does not filter an “out_of_stock” products

I am using Magento 2.3, Am filtering the product collection using the search criteria builder with a custom attribute as the filter. $filter1 = $this->_filterBuilder->setField('...
2
votes
1answer
73 views

Sort collection by discount

I want to sort my collection by discount percentage for my sale category, I don't know if it is possible in Magento
0
votes
2answers
123 views

Modify product collection in M2

I am overriding Magento\Catalog\Block\Product\ListProduct In function _getProductCollection I have added some extra code. public function _getProductCollection() { $collection = parent::...
0
votes
1answer
46 views

Not able to save an item magento 2

I have a table which store certain data in database. First i am checking if the content is already there in the database if yes then update it else insert a new data. $sync = $this->...
1
vote
0answers
36 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 ...
0
votes
1answer
92 views

is it possible to filter checkout cart collection magento 2?

Actually i want to filter the checkout cart collection using custom attributes values using this link $objectManager = \Magento\Framework\App\ObjectManager::getInstance(); $quoteId = $objectManager-&...
0
votes
0answers
22 views

How to get all categories and products in one collection in magento 2

How to get all categories(with levels) and it's products in one collection in magento 2
0
votes
0answers
101 views

Magento 2.3 collection factory not exist

I use magento 2.3 and I can't see collectionFactory created in generated folder or inject to any class. ModelFactory can create normally. There are my code: Model file: <?php namespace Lights\...
0
votes
1answer
36 views

How to call save method in collection instance

I was appeared Magento 2 Associate developer certification exam, in that I got the below tricky question, but I don't know the concept and answer of the question. can you have an idea regarding the ...
1
vote
1answer
29 views

Magento 1.9 collection multi conditions

I read many posts and articles but still didn't find a solution. I would like to filter my product collection with this condition: ... WHERE ('supplier_id' = 1 AND 'product_type' = 'first_type') ...
1
vote
1answer
258 views

How to delete object from collection in magento2

How to remove any object from magento 2 collection. If we have collection of products and we want to delete product which is at first index . how to delete that product without deleting it from ...
0
votes
1answer
74 views

Best seller items in category magento 2

I have used below code to filter products by category id. $_objectManager = \Magento\Framework\App\ObjectManager::getInstance(); $catalog_ids = 4; $productCollection = $_objectManager- >create('...
0
votes
2answers
268 views

Filter sales/order collection according to country

I would like to filter out my home country (GB or United Kingdom) from the following sales/order collection. How can this be done? $orders = Mage::getModel('sales/order')->getCollection() ...
0
votes
0answers
15 views

Set a permanent limit on returned rows in grid

I have created a grid extending Mage_Adminhtml_Block_Widget_Grid. Within _prepareCollection I'm doing this: $collection->getSelect()->limit(10); But as soon the reset filter button is clicked ...
0
votes
2answers
184 views

Magento 2: get latest Bestseller collection

I am fetching Bestsellers like this: protected $_collectionFactory; \Magento\Sales\Model\ResourceModel\Report\Bestsellers\CollectionFactory $collectionFactory, $this->_collectionFactory = $...
0
votes
2answers
238 views

Get Product Collecton by category with filters in magento 2

I need to filter category product collection with Instock items and only simple products. I have used below code to implement it.But the out of stock products also fetching with the collection. ...
0
votes
1answer
45 views

AND inside OR in where condition in getCollections() [duplicate]

Need to generate the following query with getCollection() however unable to figure it out. (id_path = '12/xyz') OR (request_path = '/abc' AND store_id = '1') Tried the following but I need it the ...
0
votes
0answers
74 views

Best seller collection filter magento2

I am trying to filter Best seller product collection like below. Seems the setOrder is not working. class BestSeller extends \Magento\Framework\View\Element\Template { protected $...
1
vote
1answer
425 views

Magento 2 How to get customer collection from website id?

I want to get collection for customer website wise. I have a website id, and now I want all the customers which belong to that particular website id. I am trying here: using \Magento\Customer\Model\...
0
votes
0answers
89 views

Magento 1.9.4 add custom dropdown field to inventory tab

Currently in magento when you manually change the quantity of a stock managed product in the admin there is no reason assigned to this. So, what I would like to do is add a dropdown field below the ...
0
votes
1answer
125 views

Magento 2 custom module Collection join table _initSelect

My Collection.php .... public function __construct( \Magento\Framework\Data\Collection\EntityFactoryInterface $entityFactory, \Psr\Log\LoggerInterface $logger, ...
0
votes
1answer
25 views

Custom attribute saved but not loaded in collection?

I added a custom attribute is_featured to my Magento 1.7 store. Its a yes/no dropdown. I am setting it to yes on storeview level and to no on the standard level. Now I try to load a collection with ...