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

All Questions

Tagged with
0
votes
2answers
37 views

I need to filter product collection by category id and color attribute

I need to get product collection by category id and color attribute. But It's not working. Here is my code: $objectManager = \Magento\Framework\App\ObjectManager::getInstance(); $categoryFactory = $...
1
vote
1answer
17 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
29 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
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 ...
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
2answers
120 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
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
112 views

Magento 2: Parsing Item information through block

I want to create a phtml file and create a dynamic block with that one to put on CMS pages - Take it as product information blocks where i want to display the product name, the price, the URL - ...
1
vote
1answer
21 views

Alter getProduct collection

I need to alter the equivalent of native "getProductCollection", but I don't know how and where to do this. I need the getProductCollection to look like this : public function getProductCollection() ...
2
votes
2answers
112 views

Magento 2 Get Product ViewCount Value By Factory

Trying to get most viewed product view count value, I need to use it in another method calculations. E.g.(if most viewed product view count value is 100 then I need this value to be returned) What am ...
1
vote
1answer
310 views

How to ignore not avilable products from best seller product collection?

app/code/Test/Demo/Block/Widget/Bestsellerdproduct.php namespace Test\Demo\Block\Widget; class Bestsellerdproduct extends \Magento\Framework\View\Element\Template implements \Magento\Widget\Block\...
0
votes
1answer
386 views

Magento product collection override sort order with own order

I'm using Magento 1 and inside catalog/product/list.phtml I use the following code to add a custom sort order product_on_top: <?php $_productCollection=$this->getLoadedProductCollection(); $...
0
votes
1answer
97 views

Get collection with promotional products not working

I need to get a collection listing all products with a promotion, but I'm getting this error: Fatal error: Call to a member function getBackend() on boolean I tried those 2 solutions, but still ...
3
votes
1answer
736 views

Magento-2 get all products having product qty less than 5 only

I'm trying to get product collection, only the products which have the qty less than 5 in Magento 2, but I'm failing to load. use Magento\Framework\App\Bootstrap; require DIR . '/../app/bootstrap....
0
votes
2answers
49 views

Magento 2 How to load product collection, Category collection, Load product by child ID

I have some experience in M1 and M2 but am somewhat struggling to grasp how to load the child category. At the minute it loads the default M2 category with [0] or [1] next category etc. But I just ...
1
vote
1answer
2k views

Category order does not work, always sort by the entity_id desc

I have a problem with my categories, and I don´t know if this is normal or not. In Magento 2.2.2 I created a custom attribute, and added it for sorting attributes. But when I tried to order product ...
0
votes
1answer
122 views

Magento 2.2 error when tried to load product or order in external file

I tried to load a product or an order form an external file using Object Manager but everytime i receive the same err: "PHP message: PHP Fatal error: Uncaught Magento\Framework\Exception\...
1
vote
0answers
155 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 ...
2
votes
3answers
607 views

Export simple product using script in magento2 [closed]

How we get simple product collection with visibility 4 (catalog/search) with script in Magento 2?
3
votes
2answers
3k views

Get product collection by store ID on Magento 2.2

I want to get all products by store ID, so I'm doing it like this return $this->productCollection->addStoreFilter(27); productCollection is Magento\Catalog\Model\ResourceModel\Product\...
1
vote
2answers
1k views

Magento 2 - Add Custom Attribute to Product Collection without Flat Catalog EAV?

I have the below collection: $this->_collection->getSelect() ->order(new \Zend_Db_Expr('price_index.min_price / IF(e.unit_of_sale = NULL, 1, e.unit_of_sale) DESC')); This ...
0
votes
1answer
1k views

Configurable Product Collection and variants

Is there any way I can fetch all the variants of a configurable products from a product collection in Magento 2? Thanks! I would like to return the products including the attribute options and and ...
1
vote
0answers
364 views

magento 2 get product collection with custom filter on product listing page

I want to apply my custom attribute filter in category product collection? Can any one inform me for that ,i need to override which file ?
3
votes
3answers
2k views

Magento 2 : AND condition in addAttributeToFilter not giving desired result

According to answer to this related question the AND condition in addAttributeToFilter is added by adding consecutive addAttributeToFilter so my statement is something like; $_productCollection->...
1
vote
0answers
55 views

Magento 2: Use widget with standard product list template

Is there way to use the same template like the "new products" widget magento already has but with my own product collection? I know how to make a widget but i don't how to attach the standard ...
0
votes
2answers
366 views

Get SKUs of “in stock” products

I’m looking for a faster way to retrieve a list of SKUs of "in stock" products. I’m using this code $products_collection = \Mage::getResourceModel('catalog/product_collection')->...
1
vote
1answer
2k views

Magento2: Collection to SearchCriteria

How to convert $products = $this->_catalogSearchAdvanced ->getProductCollection() ->addStoreFilter($storeId) ->setCurPage($page) ->setPageSize($...
1
vote
0answers
89 views

Group by products by attribute in minicart - Magento1.9

I want to know how to group by the products of a minicart by vendor_id attribute, evidently each product has this attribute vendor_id. Then I display at the header of each group the name of the vendor,...
1
vote
1answer
595 views

Fetch details from catalog_product_flat_1 table

In catalog_product_flat_1 table, we created a custom column custom_uid & saving customer ids Assume below image is the catalog_product_flat_1 table. You can see the columns contain Product name ...
1
vote
1answer
99 views

getCollection of orders where completion date is today

I need to get a collection of all orders where the status is changed to completed today. Currently i'm doing this: $fromTime = date('Y-m-d', strtotime('yesterday midnight')); $yesterdaysOrders = ...
1
vote
2answers
206 views

How to count only enabled product from product_link collection

I've found in a template file, a code like the one below: $collection = Mage::getModel('catalog/product_link') ->getCollection() ->addFieldToFilter('product_id', $...
2
votes
1answer
113 views

How can I get products with specified attribute value

In my project trying to pull product from selected category which have a specific attribute value. $currentCategory = Mage::getModel('catalog/layer')->getCurrentCategory(); $products = Mage::...
0
votes
1answer
89 views

How to export a specific order in Magento 1

I created a button to export a specific order from admin. This button apper on each order. Then i created a function that look like this: public function expButtonAction() { Mage::app('...
1
vote
1answer
39 views

Using collection to filter

How would I use $collection = Mage::getModel('catalog/product')->getCollection(); to only return products that have a special price and my own custom attribute set to yes?
4
votes
1answer
2k views

Load additional product attributes in Wishlist

I want to show some additional product attributes in the wishlist template, but they are not loaded. On the category page it is working, so it is not an index problem. When I call $item->...
1
vote
2answers
2k views

Magento 2 Filter product collection by only stock in products

In Magento 2 how can we get a collection of products with only products that are in stock. Please help
4
votes
5answers
2k views

Magento 2 - Bestseller product collection

I am trying to get bestseller products on homepage using product collection in Magento 2. I only got Most Viewed product listing (?) and I am not getting bestseller products. Here is my code: $...
5
votes
1answer
1k views

magento2 how to sort order of product by price

It my code when I sort product by price but result not show $collection = $this->_productCollectionFactory->create(); $collection->addAttributeToSelect('*'); $collection->setOrder('price',...
1
vote
1answer
487 views

Exclude products with category id - productCollection

I am currently trying to run a productCollection to try and get a list of products that are not assigned to one or more categories. $collection = Mage::getResourceModel('catalog/product_collection'); ...
6
votes
2answers
1k views

Magento 2 get out of stock products in collection

I am trying to get all the products from the collection(both in stock and out of stock) but with no luck at all. The setting on admin needs to hide the out of stock products from frontend but I want ...
5
votes
3answers
2k views

How can I load the product collection without some products?

Actually, I want to load the product collection except for some products. I have the product ids that I don't want in the collection. For example, the product ids that I don't want in the product ...
7
votes
5answers
8k views

Get product collection by root category and all its subcategories in Magento 2?

How can I retrieve a product collection by a root category and from all its subcategories? Eg: Root Category (2 products) Subcategory 1 (2 products) Subcategory 2 (3 products) So I want to ...
3
votes
2answers
6k views

addAttributeToSelect in magento2

addAttributeToSelect is not working in magento 2. i tried below but it is loading all item. $groupCollection = $this->_productloader->create(); $groupCollection->addAttributeToFilter('sku','...
1
vote
1answer
18 views

Getting the Products which have a specific product among the Up-Sells

How can I get the list of products which have a specific product among their Up-Sells? To be more specific, I'm getting a list of products with a specific attribute; I need to remove those products ...
0
votes
1answer
683 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
1answer
910 views

addCategoryFilter() returns null

I have a method, that returns me a lowest price product and it works fine: /** @var Mage_Catalog_Model_Resource_Product_Collection $productCollection */ $product = Mage::getModel('catalog/...
2
votes
1answer
47 views

How to disbaled flat_catalog on processing time

I want to disable the flat_catalog on run time for my collection. I am adding the filters but they are causing the problem because of flat_catalog. I want to disable the flat catalog on processing ...
4
votes
2answers
367 views

Where is setDoNotUseCategoryId() declared and what does it mean?

While getting related products, cross sells and upsells and collections, the function setDoNotUseCategoryId() is used. Where is it declared and can you explain the usage? foreach ($this->...
6
votes
1answer
4k views

$item->getSku() and $item->getProduct()->getSku() return different values. Why?

Edit: originally this question was just about sales/order objects but I've found an identical problem with sales/quote objects too, so I'm editing it to include that. I also added a TL;DR at the ...
6
votes
1answer
480 views

How can I get only the Store View attributes, without the inherited Global data? I only need the diffs

I'm using the internal Magento APIs to get the product data on a store view level. I only want to get the values that are on that store view level, not the global values that in inherits. But it ...