Hi All,
How to get the stores list through REST api calls?
How to get the categories list based selected store through REST api calls?
Hi @Textile_Indus,
You can use:
/rest/V1/store/storeGroups
And you'll recieve something like:
Array ( [0] => stdClass Object ( [id] => 0 [website_id] => 0 [root_category_id] => 0 [default_store_id] => 0 [name] => Default ) [1] => stdClass Object ( [id] => 1 [website_id] => 1 [root_category_id] => 2 [default_store_id] => 1 [name] => Main Website Store ) )
Or you can use
/rest/V1/store/storeViews
And you'll get
Array ( [0] => stdClass Object ( [id] => 1 [code] => default [name] => Default Store View [website_id] => 1 [store_group_id] => 1 ) [1] => stdClass Object ( [id] => 0 [code] => admin [name] => Admin [website_id] => 0 [store_group_id] => 0 ) )
Using the store code you can try this:
/rest/default/V1/categories
(default is the store code)
And you'll get
stdClass Object ( [id] => 2 [parent_id] => 1 [name] => Default Category [is_active] => 1 [position] => 1 [level] => 1 [product_count] => 0 [children_data] => Array ( [0] => stdClass Object ( [id] => 3 [parent_id] => 2 [name] => My sample category [is_active] => 1 [position] => 1 [level] => 2 [product_count] => 23 [children_data] => Array ( ) ) [1] => stdClass Object ( [id] => 4 [parent_id] => 2 [name] => Another category [is_active] => 1 [position] => 2 [level] => 2 [product_count] => 0 [children_data] => Array ( ) ) ) )
Hi Damian Culotta,
Thanks for your replay.
Now am able to get the stores list based on as you suggested.
But I was unable to get the categories list based on selected store.
I created one store i.e, "ItyugStore1". I mapped one root category(i.e, "CustomRootCategory") to this store. Here Root Category have 10 sub categories.
How to get the categories list based selected store through REST api calls?
If you make this request:
/rest/your_store_view_code/V1/categories
You'll get the category tree per store view.
Use the firsts requests to obtain the codes and then this one to get the categories.
Hi, The solution is working fine with the store code 'default' which is a default store. I have created a new store with the store code as 'wholesale'. But with this store code I am getting error message as
stdClass Object ( [message] => Specified request cannot be processed. )
My request URL as below
$requestUrl='http://mydomain.com/rest/wholesale/V1/categories';
I am getting this same error on a custom API endpoint. did you manage to solve this?
@imaphpdeveloper wrote:Hi, The solution is working fine with the store code 'default' which is a default store. I have created a new store with the store code as 'wholesale'. But with this store code I am getting error message as
stdClass Object ( [message] => Specified request cannot be processed. )
My request URL as below
$requestUrl='http://mydomain.com/rest/wholesale/V1/categories';