Skip to content
NewRedesigned blogFeedback
Jigar Karangiya

how to get shared catalog data by ID in Magento 2?

You can get Shared Catalog data by shared catalog id programmatically. Magento\SharedCatalog\Api\SharedCatalogRepositoryInterface Interface used to get, delete and save Shared catalog related things.

how to get shared catalog data by ID in Magento 2?
Written by
JKJigar Karangiya
Published
Reading time
1 min read

Jigar Karangiya · · 1 min read

Magento gives you the ability to maintain shared catalogs (opens in new tab) with the custom pricing structure for different companies.

You can get Shared Catalog data by shared catalog id programmatically.
Magento\SharedCatalog\Api\SharedCatalogRepositoryInterface Interface used to get, delete and save Shared catalog related things.

php
<?php
class YourClass {
 
    public function __construct(
        \Magento\SharedCatalog\Api\SharedCatalogRepositoryInterface $sharedCatalogRepository
    ) {
        $this->sharedCatalogRepository = $sharedCatalogRepository;
    }
 
    public function getSharedCatalog()
    {
        $sharedCatalogId = 1;
        $sharedCatalog = $this->sharedCatalogRepository->get($sharedCatalogId);
        print_r($sharedCatalog->debug(),true); //to debug shared catalog data
        return $sharedCatalog;
    }
}

You can then use it using by calling function $this- >getSharedCatalog();

If you will print the output of the function it will return result like below.

Output :

javascript
[
    "entity_id" => "1",
    "name" => "Default (General)",
    "description" => "Default shared catalog",
    "customer_group_id" => "1",
    "type" => "1",
    "created_at" => "2023-05-16 11:55:38",
    "created_by" => "19",
    "store_id" => "0",
    "customer_group_code" => "Default (General)",
    "tax_class_id" => "3",
  ]

As you can see in the above result, you will get shared catalog-related data like Id, Name, Customer Group Id, etc.

You will also like this :

Get Company Admin using company ID programmatically Magento 2 B2B.

That’s it. Thanks for reading. Keep coding !!

Keep reading
All posts

Newsletter

New Magento tutorials, straight to your inbox

Code examples, performance tips, and fixes for common Magento issues. No spam.

Subscribe