The Stack Overflow podcast is back! Listen to an interview with our new CEO.

Questions tagged [collection]

Questions related to Magento collections

Filter by
Sorted by
Tagged with
1
vote
2answers
81 views

Get recently viewed product collection Magento 2.3.1

I have tried this but it is not working. I am getting blank array. Suggestions please, i am stuck. I want to display recently viewed product in owl carousel. But getting no products. protected $...
0
votes
2answers
80 views

How to get value from sales_flat_order_item table using quote_item_id?

Using the sales_order_place_after event in my custom Observer. I have the quote_item_id value (example 324). How to get the corresponding item_id value from the sales_flat_order_item table? I am ...
0
votes
0answers
21 views

Magento 2 how to match one item from one collection to another item in another collection if both are same then add to an array

I'm trying to compare two values from collection to another two values from another collection if they both are same then add that row to a array. How to achieve it. Can I get help? Thank you in ...
0
votes
2answers
195 views

how to update data in database table

I am sending data to the database by checking duplicate data. But I can't be inserting/updating data in the database. protected function saveEntityFinish(array $entityData, $table) { $...
1
vote
0answers
30 views

Magento 2 : Need to set custom category collection using plugin

I want to set custom category collection using the plugin. I created plugin about Magento\Catalog\Block\Product\ProductList\Toolbar this block and aroundSetCollection(). But, not actual output I ...
1
vote
0answers
20 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(); $...
6
votes
2answers
226 views

Empty Collection :: CollectionFactory Approach and getCollection approach both give empty result

Magento 2.3.1 Php7.2 Ubuntu 18.04 I have created a table in my database using db_schema.xml and then populated that table with sql insert commands directly in mysql workbench. My model code is &...
2
votes
3answers
438 views

Magento2 Alternate of Method getCollection() which is deprecated

I have checked the similar post: Magento2.2 getCollection from Factory deprecated But I still don't find the answer of it. I am calling getCollection() function, and PHPStorm saying that this ...
0
votes
1answer
54 views

Magento 2 : AddAttributeToFilter with AND Condition

In product collection, I want to do like : $productCollection = $this->productCollectionFactory->create(); $productCollection->addCategoriesFilter(['in' => $catalog_id])->...
0
votes
1answer
61 views

Recevied Empty array after using getItemsByColumnValue() collection method

I'm trying to retrieve a row from a custom table named 'lmap_shipping_tablerate' using a specific value for a column postcode. An empty array is returned when following line is used in my ...
0
votes
2answers
77 views

How to pass added custom “key=>value” into getCollection()?

On product lisitng page i want to get one more parameter "latitude" for all product,how can i achieve? Here is my code:- public function setCollection($collection) { $this->...
2
votes
1answer
204 views

How to filter customer collection with its attribute?

I've bunch of customer attributes, So how can I filter customer collection with its custom attribute ?
1
vote
1answer
42 views

Unable to display database table values on frontend in magento 2.1.7

I am trying to fetch table on frontend but getting this error Fatal error: Class 'Crud\Crudatfrontend\Model\ResourceModel\Post' not found in D:\xampp\htdocs\newmag\vendor\magento\framework\...
1
vote
2answers
205 views

How to update record using multiple conditions in CollectionFactory magento 2

I am trying to update the record but it creates a new record. Collection factory <?php namespace Webkul\Mpquotesystem\Block; use Webkul\Mpquotesystem\Model\ResourceModel\Quoteconversation; ...
0
votes
1answer
30 views

How can get custom table columns on product listing page using product_id of the custom table

On product listing page, I need to show visitor nearest product first. I've a marketplace site and each product have different seller and there is a custom table having seller_id and product_id ...
1
vote
2answers
75 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
52 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
39 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
57 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
636 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
460 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
47 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
43 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
101 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
35 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" ...
3
votes
0answers
37 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
1answer
83 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
80 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
677 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
211 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
37 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
274 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
74 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
31 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
28 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
131 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
133 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
151 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
86 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
516 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
32 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
315 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
36 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
223 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
112 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
266 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
58 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
42 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
145 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
23 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