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

0
votes
1answer
15 views

How to join Sales order collection and order item collection

I want to join the sales order collection and sales order item collection How to join the two collection I have collections like order collection > $ordercollection=$this->orderCollection-...
0
votes
1answer
18 views

Sort product collection on stock status in magento2.3

I want to sort my list.phtml and catalogsearch by availability. Mean that when category page or search result page loads, first show "in stock" product and at the end show out of stock items. Don't ...
0
votes
1answer
16 views

Magento2 admin grid: SQL error when sorting by specific field

Database table columns are displayed in custom grid in adminhtml. One of the field has name 'precision' and this causes SQL error when I sort the grid by this field (as this is mysql reserved word and ...
0
votes
0answers
11 views

How can we modify collection getSize() value after, removing some keys by removeItemByKey()

I need to remove some row from collection. So i used removeItemByKey(). But I need to also change getSize() and count(), which is coming wrong after removing keys. My code is public function ...
2
votes
1answer
78 views

Magento 2 - All products attributes updated after update from collection

I have got collection in $collecction from Magento\Catalog\Model\ResourceModel\Product\CollectionFactory with some certain conditions I am updating a custom attribute viewed_count in foreach loop ...
0
votes
0answers
22 views

Set a default filter for Order Grid

How can I set a default filter for Order Grid programmatically? I read many different answer but they don't work properly.
1
vote
1answer
41 views

Magento 2 - Need to filter comma sperated values in addAttributeToFilter along with category filter

I need to filter comma sperated values in addAttributeToFilter in magento 2 Here is my Code: $comma_separated_values = 26,27,28,29; $categoryProducts = $category->getProductCollection()->...
0
votes
3answers
29 views

custom table left join with catalog/product

I have a custom table called flagged_products which lists flagged products like this: +-----------+------------+---------------------+ | entity_id | product_id | flagged_on | +-----------+---...
1
vote
1answer
15 views

How to get product random collection in magento2?

I want to get the random 10 products from whole product collection in magento2. $productCollection = $this ->productModel ->getProductCollection() ->...
0
votes
1answer
26 views

array convert into Magento 2 collection

I have 2 collection 1 is $bestsalecollection that show in dashboard . second is product collection. After filter collection when i return it generate error Call to a member function isLoaded() on ...
0
votes
0answers
19 views

Why product collection query not showing “color” attribute in select?

Case 1: $collection = $this->product->getCollection() ->addAttributeToSelect('color'); echo $collection->getSelect()->__toString(); Output: SELECT `e`.* FROM `...
0
votes
0answers
21 views

Call to a member function isLoaded() on array

Call to a member function isLoaded() on array in /var/www/html/codility-magento-market-place/vendor/magento/module-backend/Block/Widget/Grid/Extended.php:473 Stack trace $bestsalecollection = $this-&...
3
votes
1answer
25 views

Custom FilterList incorrectly sets Collection size in Layered Navigation

In order to add a custom filter to the Layered Navigation, I overrode the class Magento\LayeredNavigation\Block\Navigation\Category to load my own FilterList class instead of the one from core. My ...
1
vote
1answer
20 views

Magento 2 - Recently viewed product collection from Model

Please read description carefully before marking it as duplicate I want to get recently viewed product collection from Model instead of Block I have check similar post but no one answered it ...
0
votes
0answers
13 views

Incorrect product sorting for numerical attributes (Magento 2.2.8)

I've got a shop with an attribute "capacity" created via Magento Backend: Shops -> Attribute -> Product It has "Text Field" as input type and "Decimal" as validation. So for new products therefore ...
0
votes
0answers
16 views

Set custom Record Count to Collection pagination in Report Grid

How we can set count of collection size before setting for the grid. Main Sales collection: $collection=Mage::getModel('sales/order')->getCollection() ->addAttributeToFilter('created_at', ...
3
votes
2answers
48 views

Magento 2.3 - Add product name column in custom ui grid with product name filter

I have added product name column in my custom ui grid. In which data displayed properly but not filtered grid by product name. Note : I set product name with comma separated in ui grid column. Here ...
2
votes
1answer
26 views

Magento 2 - Multiple collection on same block

I have a block where I want 3 different collections with different category filters. I have created collection object in constructor like this: protected $collection; public function __construct( ...
0
votes
0answers
15 views

Magento 1.9.3.1 Sales Order Grid limit records

I have a Magento store running with over 18,000 order records all the other pages within admin load within 1 - 2 seconds apart from Sales>Orders this can take anything between 5 - 20 seconds to load. ...
3
votes
1answer
17 views

Magento 2 - Multiple categories filter on product collection

I have a product collection $collection which is created by Magento\Catalog\Model\ResourceModel\Product\Collection code is: $collection = $objectManager->create('Magento\Catalog\Model\...
0
votes
0answers
18 views

Magento 2.3 custom conditions for attribute filter using addAttributeToFilter

In Magento 2.3 I need to filter the collection as per below scenario. I have L, W and H attributes for products And user input is "X, Y and Z" then the following condition will give the desired ...
1
vote
1answer
22 views

Magento 2 call list.phtml with custom collection

I have custom collection in $collection I want to pass it to list.phtml so that I don't have to create listing UI again. I am trying to do this but it is not working <?php echo $this->getLayout(...
0
votes
1answer
27 views

How to use Magento 2 cache?

I have a requirement where, I have huge custom data(around 5000) to display in a page. Currently, I have displayed them in a table and it takes time when I load the page. I want to save the collection ...
2
votes
0answers
34 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/...
1
vote
2answers
56 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
28 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
1answer
35 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
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
18 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
122 views

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

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 <?php namespace Lmap\...
1
vote
2answers
97 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
37 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
30 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
46 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
49 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
34 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
70 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
35 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
36 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
30 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
21 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
213 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
118 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
32 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
25 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
0answers
19 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
23 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->...