Skip to main content
added 596 characters in body
Source Link
Meetanshi
  • 989
  • 2
  • 7
  • 22

Please try this

$storeid<?php
namespace Meetanshi\Example\Block;
class Product extends \Magento\Framework\View\Element\Template
{    
    protected $_productCollectionFactory;
        
    public function __construct(
        \Magento\Backend\Block\Template\Context $context,        
        \Magento\Catalog\Model\ResourceModel\Product\CollectionFactory $productCollectionFactory,        
        array $data = 27;[]
$objectManager    )
    {    
        $this->_productCollectionFactory = \Magento\Framework\App\ObjectManager$productCollectionFactory;    
        parent::getInstance__construct($context, $data);
    }
$productCollectionFactory = $objectManager->get  
    public function getProductCollection('\Magento\Catalog\Model\ResourceModel\Product\CollectionFactory');
    {
        $storeid = 27; 
        $collection = $productCollectionFactory$this->_productCollectionFactory->create();
        $collection->addAttributeToSelect('*');
        $collection->addStoreFilter($storeid);        
        return $collection;
    }
}
?>   

Hope this will help and make sure the id you are passing is available.

Please try this

$storeid = 27;
$objectManager = \Magento\Framework\App\ObjectManager::getInstance();  
$productCollectionFactory = $objectManager->get('\Magento\Catalog\Model\ResourceModel\Product\CollectionFactory');
$collection = $productCollectionFactory->create();
$collection->addAttributeToSelect('*')
$collection->addStoreFilter($storeid);

Hope this will help and make sure the id you are passing is available.

Please try this

<?php
namespace Meetanshi\Example\Block;
class Product extends \Magento\Framework\View\Element\Template
{    
    protected $_productCollectionFactory;
        
    public function __construct(
        \Magento\Backend\Block\Template\Context $context,        
        \Magento\Catalog\Model\ResourceModel\Product\CollectionFactory $productCollectionFactory,        
        array $data = []
    )
    {    
        $this->_productCollectionFactory = $productCollectionFactory;    
        parent::__construct($context, $data);
    }
    
    public function getProductCollection()
    {
        $storeid = 27; 
        $collection = $this->_productCollectionFactory->create();
        $collection->addAttributeToSelect('*');
        $collection->addStoreFilter($storeid);        
        return $collection;
    }
}
?>   

Hope this will help and make sure the id you are passing is available.

Source Link
Meetanshi
  • 989
  • 2
  • 7
  • 22

Please try this

$storeid = 27;
$objectManager = \Magento\Framework\App\ObjectManager::getInstance();  
$productCollectionFactory = $objectManager->get('\Magento\Catalog\Model\ResourceModel\Product\CollectionFactory');
$collection = $productCollectionFactory->create();
$collection->addAttributeToSelect('*')
$collection->addStoreFilter($storeid);

Hope this will help and make sure the id you are passing is available.