0

enter image description here

        $products = $this->productFactory->create()
                                ->setStoreId($store_id) //this is not working
                                ->getCollection()
                                ->addAttributeToFilter('status', 1)
                                ->addAttributeToFilter('visibility', '4')
                                ->addAttributeToSelect('*');

I want products of Slovenian Website, not Main. Please help me.

1 Answer 1

2

Try this

protected $_productCollectionFactory;

public function __construct(
    .......................................
    \Magento\Catalog\Model\ResourceModel\Product\CollectionFactory $productCollectionFactory,        
    .......................................
)
{    
    .......................................
    $this->_productCollectionFactory = $productCollectionFactory;    
    .......................................
}

public function getProductCollection()
{
    $storeid = 2; 
    $collection = $this->_productCollectionFactory->create();
    $collection->addAttributeToSelect('*');
    $collection->addStoreFilter($storeid);        
    return $collection;
}
0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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