Skip to main content
edited
Source Link
MR.R DNATH
  • 462
  • 2
  • 10

You have to make filter like this way

`$filterVariable = array(460,4,98);

$this->_productCollection ->addFieldToFilter('entity_id',array('in'=> $filterVariableYou were doing the filter after category filter,so it may be that product is not in current category.That why your collection was returning Null. ));`.

Means you haveBetter way to make an array variable like this

$myarray = array(); foreach($productIds as $_productId) { $myarray[] = $_productId; } $this->_productCollection ->addFieldToFilter('entity_id',array('in'=> $myarray));filter by product ids is

Let me know if face any other issue.

$productIDS =  array(460,4,98);
$collection->addIdFilter($productIDS);

You have to make filter like this way

`$filterVariable = array(460,4,98);

$this->_productCollection ->addFieldToFilter('entity_id',array('in'=> $filterVariable ));`

Means you have to make an array variable like this

$myarray = array(); foreach($productIds as $_productId) { $myarray[] = $_productId; } $this->_productCollection ->addFieldToFilter('entity_id',array('in'=> $myarray));

Let me know if face any other issue.

You were doing the filter after category filter,so it may be that product is not in current category.That why your collection was returning Null. .

Better way to filter by product ids is

$productIDS =  array(460,4,98);
$collection->addIdFilter($productIDS);
Source Link
MR.R DNATH
  • 462
  • 2
  • 10

You have to make filter like this way

`$filterVariable = array(460,4,98);

$this->_productCollection ->addFieldToFilter('entity_id',array('in'=> $filterVariable ));`

Means you have to make an array variable like this

$myarray = array(); foreach($productIds as $_productId) { $myarray[] = $_productId; } $this->_productCollection ->addFieldToFilter('entity_id',array('in'=> $myarray));

Let me know if face any other issue.