任何人都可以使用REST API帮助显示类别及其子类别吗?使用REST API在Magento中显示类别及其子类别
我已经试过这个网址:
http://localhost/magento/api/rest/products/:productId/categories
但它显示的不是我需要什么类ID,即是这样的:
http://localhost/magento/api/rest/categories
在此先感谢。
任何人都可以使用REST API帮助显示类别及其子类别吗?使用REST API在Magento中显示类别及其子类别
我已经试过这个网址:
http://localhost/magento/api/rest/products/:productId/categories
但它显示的不是我需要什么类ID,即是这样的:
http://localhost/magento/api/rest/categories
在此先感谢。
/api/rest/products/:productId/categories
这应该检索分配给特定产品的类别列表。不幸的是,这不会让你得到你应得的优雅解决方案。
如果您想要一个类别列表您可能需要使用soap api来检索使用catalog_categories.tree method的类别。我意识到“使用其他API”是最糟糕的答案,但它是磁电机目前提供的。
另一种方法是用自己宁静的拼凑品扩展库存api,但生命短暂。
如果你真的想要做这样的事情的话,这个其他堆栈溢出问题将帮助你开始: Create new magento Rest api to get category list in magento
确实存在仍然一无所获无论是在Magento 1.x API guide无论是在代码中找到。
您可以在Mage_Catalog
模块的文件夹结构中清楚地看到,表示类别的模型仍然只是产品的子模型,因此它的主要目标仍然是“仅”,以便能够知道特定产品的类别被链接到。
而且Mage_Catalog_Model_Api2_Product_Category_Rest
类这一类模式存在的代码看起来并不像什么的(在1.9.2.4最新版本围绕线61)从以前的答案变了,可悲的是:
protected function _retrieveCollection()
{
$return = array();
foreach ($this->_getCategoryIds() as $categoryId) {
$return[] = array('category_id' => $categoryId);
}
return $return;
}
我不确定Magento是否仍然会在框架的1.x版本中对REST API付出任何努力。
虽然似乎有希望在Magento 2.x API list列出那些可用的方法:
DELETE/V1 /分类/:CATEGORYID
GET/V1 /分类/:CATEGORYID
POST/V1 /类别
GET/V1 /类别
PUT/V1 /类别/:ID
PUT/V1 /类别/:的categoryId /移动
此代码还提供了获取类别树的可能性。
参见here和there。
所以这绝对是Magento 2.x下可能的东西