Php 获取Akeneo中的类别列表

Php 获取Akeneo中的类别列表,php,symfony,akeneo,Php,Symfony,Akeneo,Akeneo文件中给出了以下代码: . 在执行代码时,它给出如下结果 RESULT:{“resource”:“http:\/\/akeneo pim.local\/api\/rest\/products\/OROMUG\u DBO”,“family”:“mugs”,“groups”:OMUG\u OB”,“OROMUG\u ODB”]}…… 我希望以类似的方式获取Akeneo中的类别。上面的代码使用WebserviceBundle中的ProductController。我应该如何继续以类似的方式

Akeneo文件中给出了以下代码: . 在执行代码时,它给出如下结果

RESULT:{“resource”:“http:\/\/akeneo pim.local\/api\/rest\/products\/OROMUG\u DBO”,“family”:“mugs”,“groups”:OMUG\u OB”,“OROMUG\u ODB”]}……


我希望以类似的方式获取Akeneo中的类别。上面的代码使用WebserviceBundle中的ProductController。我应该如何继续以类似的方式获取类别。

事实上,Akeneo PIM目前只提供一个用于外部目的的产品REST控制器

您唯一的解决方案是创建自己的类别控制器,以从PIM中提取类别数据

这是一个很好的开始模板


您还可以查看我们的,以了解如何正确规范化类别

以下是控制器的一些示例代码,该控制器显示一个表单,允许从“打印”频道的所有现有类别中进行选择

public function indexAction()
{

    $channels = $this->channelRepository->getFullChannels(); 
    $selected_channel = null;

    /*
    * default channels are: 'print', 'mobile' 'ecommerce'
    */
    foreach($channels as $channel) {
        if('print' == $channel->getCode() ) {
            $selected_channel = $channel;
            break;
        }
    }
    $categories = [];

    /*
    * fill-in the array with the values we're interested in
    */
    if($selected_channel) {
        $category = $selected_channel->getCategory();
        $categories_ids = array_merge([$category->getId()], $this->categoryRepository->getAllChildrenIds($category));

        foreach($categories_ids as $category_id) {
            $category = $this->categoryRepository->find($category_id);
            $categories[] = array('id' =>$category->getId(), 'label' => $category->getLabel());
        }
    }

    return $this->templating->renderResponse('CfXmlBundle:Form:index.html.twig', array('categories' => $categories, 'locale' => 'en_US', 'scope' => null));
}
以及相关的细枝模板:

<form>
    <div style="clear: both; width: 100%;">
        <label>Choose a catalog:</label>
        <select name="category_id" style="width: 100%;">
        {% for category in categories %}
        <option value="{{ category.id }}">{{ category.label }}</option>
        {% endfor %}
        </select>
    </div>
    <div style="clear: both; width: 100%">
        <label>Catalog title</label>
        <input type="text" name="title" value="" style="width: 100%;" placeholder="default is choosen catalog name" />
    </div>
    <div style="clear: both; width: 100%;">
        <label>Catalog description</label>
        <textarea name="description" style="width: 100%;"></textarea>
    </div>
    <div style="clear: both;">
        <input style="float: left;" type="checkbox" name="prices" value="0" />
        <label style="float: left;">&nbsp;Show prices ?</label>
    </div>
    <div style="clear: both; text-align:right;">
        <input type="submit" value="Generate" />
    </div>    
</form>

选择目录:
{categories%%中的类别为%s}
{{category.label}
{%endfor%}
目录标题
目录说明
显示价格?