Questions tagged [collection]

Questions related to Magento collections

Filter by
Sorted by
Tagged with
0
votes
0answers
13 views

magento 2 how to add search box to fronted for a custom table contents

How to add a frontend search box for a custom table contents. When the user enters three letters of a name then get data in pop up. Anyone Can help? Thank you in advance.
3
votes
1answer
46 views

Magento 2 Updating Other Products in catalog_product_save_after event Observer

I had created an Observer of this event:catalog_product_save_after I am trying to update other products and loading them on the basis of their id, but it is giving me an error. I am Sharing my code ...
0
votes
1answer
630 views

How i can join eav_attribute_option_value table into my collection and get from him “frontend_label” of colors?

I have a products collections. But in "color" i see option_id number. Mage::getModel('catalog/product') ->getCollection() ->addStoreFilter(Mage::app()->...
1
vote
0answers
20 views

How i can work with extension attributes using collection?

Hello i have to add extension attributes to Magento\Catalog\Api\Data\ProductInterface So i added this one to extension_attrributes.xml: <config xmlns:xsi="http://www.w3.org/2001/XMLSchema-...
1
vote
1answer
24 views

Magento2 Need to build Grid with multiple table collection using layout

I need to build admin grid with data displaying in grid from 2 table. For 1st table I can simply display using giftcardaccount_id but I don't know how to join this & then display the data from ...
2
votes
6answers
192 views

Date Range filter not working in custom Grid Magento 2

I have created the custom sales report using ui component. Grid is loading correctly. I have added the date range filter as like below. <column name="created_at" class="Magento\Ui\Component\...
0
votes
4answers
662 views

How to limit the results from a Left Join in Magento?

I have a collection that I need to join with another collection... the problem is the table contains 125k rows and so it times out. //Fields $this->addFieldToSelect('id'); $...
1
vote
2answers
896 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 (...
2
votes
1answer
223 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 ...
0
votes
1answer
25 views

Magento 2: How to filter orders by order items

In magento 1, I was able to filter orders by the following: $orderitem = Mage::getModel('sales/order_item')->getCollection(); $orderitem->addFieldToFilter('name',array('like'=>'%'.$value.'%')...
2
votes
1answer
50 views

Magento 2 - Need to filter comma seprated 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
0answers
14 views

Magento 2 collection filters for GRID are not working

I'm developing a module for Magento 2, but when trying to create a GRID, my filters are not working. I have some settings in other class and load it to the collection, using it inside the ...
2
votes
3answers
173 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 ...
3
votes
1answer
622 views

Magento 2 : Is there a way to query products using Custom Attributes in Rest API Call?

I have a custom attribute setup for Books called isbn_13 Now I try to find the products using the isbn_13 values but unable to filter the results based on this. Is there any way to do this? Update: ...
4
votes
1answer
799 views

How set order with custom field column magento 2

I want to setOrder with custom field column in get list product. I override toolbar.php but it's not working di.xml <?xml version="1.0"?> <config xmlns:xsi="http://www.w3.org/2001/XMLSchema-...
0
votes
1answer
13 views

magento 1.9 | how setStockData on collection

i have this code $productCollection = Mage::getModel('catalog/product')->getCollection(); $productCollection->addAttributeToSelect('SKU') ->addAttributeToFilter('...
1
vote
3answers
26 views

Magento 2 + custom eav field value store in array

I have a custom eav structure and there is store_id save in array format in the database field. I need to filer collection with addFieldToFilter with store_id. $collection = $this->...
6
votes
2answers
163 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
0answers
8 views

How to create a pagination on product page for the reviews

I am trying to create pagination on product page just to keep the review down. I have over 50 reviews for product is there anyway I could limit it to 10. Is there anyway I could follow some codes or ...
1
vote
1answer
20 views

How add new item in existing collection in magento 2

i have 2 collections 1 Orders 0 date "2019-07-05" count "2" 1 date "2019-06-20" count "2" 2 date "2019-06-18" count "2" 3 date "2019-06-17" count "2" 4 date "...
0
votes
1answer
27 views

Magento 2 - how to use count and group by clause in collection

i have order collection and want to this query result like `SELECT `created_at`,COUNT(`entity_id`) FROM `sales_order_item` GROUP BY `created_at`; i use this query `$selectCollection=$this->...
1
vote
2answers
2k views

Magento:2 How to Image upload in custom module

Image upload working fine in tmp folder, then store in DB. I want to after saving data image stored in the base folder pub/media/events var_dump($data); " ["events_url"]=> array(1) { [0]=> ...
0
votes
1answer
701 views

Get product collection based on entity_id in magento2

How to Create product collection with filter based on entity_id in Magento 2? I tried below: $model = $this->_objectManager->create('Vendor\MOdule\Model\Queue'); $ProductId = $this->...
0
votes
3answers
28 views

Set order for product Collection in magento2

I am filtering product collection like below. $productSkuString = 'O, C, D, A, F, S'; $productSkus = explode(', ', $productSkuString); $collection = $this->collectionFactory-&...
1
vote
2answers
21 views

difference in result of count and getSize()

I am preparing the product collection as follows $visibleProducts = $this->catalogProductVisibility->getVisibleInCatalogIds(); $collection = $this->productCollectionFactory->create(); $...
2
votes
1answer
22 views

Magento catalog price rule

How to get product based on conditions on catalog rule in magento2? By product model products are received but how to apply filter to get only those product based on conditions. Any help will be ...
1
vote
1answer
872 views

How to get all products collection for special category

I am looking for function which is similar to getLoadedProductCollection and which retrieves all products from this category with selected filters, not only those I can see on current page like ...
0
votes
0answers
23 views

Magento 2 create new tab and add customer grid collection on product add/edit page in admin

I am using magento 2.3 and i want add custom tab in Product edit page on admin and add grid collection of customer in custom tab. So any one know How i can do that. Thank you.
0
votes
5answers
2k views

Magento 2.1 UI component form addFieldToFilter() on null

I am trying to make a UI component form for creating products in Magento 2.1 module. However, I stuck with the problem that it throws this error: Fatal error: Method Magento\Ui\TemplateEngine\...
1
vote
2answers
4k views

Getting 404 error on category page

I have 2 root categories and subcategories in every one of them. One of root category(Default Category) and sub categories are showing on navigation menu. It's OK. That's what I want. The other root ...
1
vote
1answer
34 views

Magento 2: How to add multilevel AND and OR conditions to searchCriteria?

What i want to achieve is this - attr1 = 'val1' AND attr2 = 'val2' AND ((attr_s1 = 'val_s1' AND attr_d1 = 'val_d1' AND attr_t1 = 'val_t1') OR (attr_s2 = 'val_s2' AND attr_d2 = 'val_d2' AND ...
0
votes
0answers
17 views

Magento 2 product collection getSelect Order by Case unException Unknown column 'name' in 'order clause'

I need to use ORDER BY CASE name which is product name Query: SELECT `e`.*, `cat_index`.`position` AS `cat_index_position`, `stock_status_index`.`stock_status` AS `is_salable` FROM `...
0
votes
1answer
33 views

Magento 2: How to get sub category and their products in collection?

I want to get the categories and related products in collection using parent category ID. So that i can show the grid like sub category 1 sub category 1's product 1 sub category 1's product 2 sub ...
0
votes
1answer
67 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 : ...
3
votes
2answers
60 views

collection, get product image

Sorry for my English I have this code $productCollection = Mage::getModel('catalog/product') ->getCollection() ->addAttributeToSelect('short_description') ->...
2
votes
1answer
26 views

Difference between $this->getData() or $this->getResource()

In my Collection.php when i get the collection by $this->getData() is give me collection. But it create some other problem for me . Now i use $this->getResource() then problem solved But it ...
3
votes
1answer
33 views

Magento 2: Getting unknown category

I am trying to get a level 2 category list. I got all level 2 categories but I am also getting 2 unknown categories which are not in backend. This is weird. Here is my code public function ...
0
votes
2answers
28 views

Magento 1 | how get product attribute data

Sorry for my English. I have this code. $productCollection = Mage::getModel('catalog/product') ->getCollection() ->addAttributeToFilter('attribute_set_id',array(12,4)) ...
0
votes
1answer
793 views

process collection after load collection

$categoryid = 43; $layer = Mage::getModel("catalog/layer"); $category = Mage::getModel("catalog/category")->load($categoryid); $layer->setCurrentCategory($category); $attributes = $layer ...
0
votes
1answer
14 views

Magento1 | Collection how get all products where qty > 1, build query

I have this code $productCollection = Mage::getModel('catalog/product') ->getCollection() ->addAttributeToFilter('attribute_set_id',array(12,4)) ->setPageSize(...
0
votes
0answers
16 views

Difference between Magento Collection ,object , array

Please clear the main difference between Magento Collection , object , array and arraylist also ?
1
vote
2answers
358 views

Remove default fields from Product Collection

I have a product collection object (Mage_Catalog_Model_Resource_Product_Collection). I am adding various attributes to the select via addAttributeToSelect(). How do I remove the default attributes e....
0
votes
1answer
874 views

Getting Notice Notice: Use of undefined constant sales_flat_order_status_history - assumed 'sales_flat_order_status_history'

I have created below collection query in my custom external magento page-- <?php $mageFilename = 'app/Mage.php'; require_once $mageFilename; Mage::setIsDeveloperMode(true); ini_set("...
79
votes
6answers
67k views

Difference between getSize() and count() on collection

I have heard many times that they both are the same. But I am facing a weird issue, in the product collection of CatalogSearch module, count() is returning correct product count while getSize() is ...
0
votes
0answers
17 views

How to get magento2 bundle products in list page

How to get magento2 bundle products in category list page. I assigned to category but not visible in frontend. Thanks
6
votes
3answers
4k views

Magento 2 - Layered Navigation for Custom Product Collection

I created a CMS page for products that contain a certain attribute (On Sale Items). I extended the ListProduct class and added filters to the product collection to achieve the desired results. (...
0
votes
1answer
45 views

recently viewed product collection is empty in magento 2

I have added a code in Magento_Catalog/layout/catalog_product_view.xml <referenceBlock name="product.info.details"> <block class="Magento\Reports\Block\Product\Widget\Viewed" name="...
10
votes
4answers
18k views

Magento 2: How to Filter a Product Collection By Store ID

Using a product factory object, I'm able to create a product, grab a product collection, and fetch the first item of that collection /* var $productFactory \Magento\Catalog\Model\ProductFactory */ $...
1
vote
1answer
28 views

How is a product name retrieved if the query does not return it in the result set?

I'm trying to get data from catalog_product EAV tables with the following code: $productCollection = Mage::getModel('catalog/product')->getCollection() ->addAttributeToFilter('...
1
vote
1answer
910 views

Magento-2 How to get custom product collection in catalog search result based on particular category

I am working on custom module for catalog access. It requires only logged in customer to access the assigned category products. Right now in catalog search result, product collection displays all the ...