cancel
Showing results for 
Search instead for 
Did you mean: 

Get store specific category in magento 2

SOLVED

Get store specific category in magento 2

Hello all,

Can any one help me to get store specific category in magento 2

2 ACCEPTED SOLUTIONS

Accepted Solutions

Re: Get store specific category in magento 2

Re: Get store specific category in magento 2

Hi @jenny09yop1298 

please use the below code:

public function __construct(
    \Magento\Catalog\Model\CategoryFactory $categoryFactory
) {
    $this->categoryFactory = $categoryFactory;
}
  
public function execute()
{
    $category = $this->categoryFactory->create()->setStoreId(2)->load(4);   //here 2 is the store id of the second store
}

If it helps you, please accept it as solution and give kudos.

Regards

 

View solution in original post

3 REPLIES 3

Re: Get store specific category in magento 2

Hello @jenny09yop1298 

 

You can refer https://magento.stackexchange.com/questions/128547/how-to-get-category-collection-per-store-in-magen... for the solution.

 

Hope it helps.

Problem solved? Click Kudos and "Accept as Solution".
200+ Magento 2 Extensions for Enhanced Shopping Experience.

Re: Get store specific category in magento 2

@jenny09yop1298 you can check the below link once.

https://webkul.com/blog/how-to-load-store-specific-category-in-magento-2/

 

Hope it helps.

 

Thanks

Re: Get store specific category in magento 2

Hi @jenny09yop1298 

please use the below code:

public function __construct(
    \Magento\Catalog\Model\CategoryFactory $categoryFactory
) {
    $this->categoryFactory = $categoryFactory;
}
  
public function execute()
{
    $category = $this->categoryFactory->create()->setStoreId(2)->load(4);   //here 2 is the store id of the second store
}

If it helps you, please accept it as solution and give kudos.

Regards