0

I'm using the MageWorx autocomplete, but it display the child products from bundles

  • What do you want to display? – Chirag Patel Apr 30 at 4:51
  • You have display bundle product instead os child product? – Chirag Patel Apr 30 at 4:52
1

You can't get child products and parent products i have tried all and finally use this custom query to get all products parent, child.

$connection= $this->_resources->getConnection();
                        $select = $connection->select()
                            ->from(['o' =>  $this->_resources->getTableName('catalog_category_product')]);
                        $select->where('category_id = ?', $subcat->getId());
                        $result = $connection->fetchAll($select);

                    $productIds = array();
                    foreach ($result as $product)
                    {
                        $productIds []= $product['product_id'];
                    }

Here you get all product ids of specific category now create a collection factory of \Magento\Catalog\Model\ResourceModel\Product\CollectionFactory and filter your products

    $collection = $this->CollectionFactory->create();
                        $collection->addFieldToFilter('entity_id',array('in',$productIds));

Do what you like with the products

foreach ($collection as $product)
                        {
                            $productname = $product->getname();
                        }

If this helps accept and vote it

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.