Reply
 
Thread Tools Display Modes
  #1  
Old 04-27-2012, 11:32 AM
Ejub Bicic @ejubbicic's Avatar
Ejub Bicic @ejubbicic Ejub Bicic @ejubbicic is offline
 
Join Date: May 2011
Location: Sweden
Posts: 12
Default Category Menu Item Order - API

Hi!

I have created a custom category menu using the API. The API returns parent categories and subcategories, but in the wrong order. In other words, the menu items are not returned in the order I have sorted them in Ecwid backend.

Is there a way to get the menu items in the order set?

My code is:
PHP Code:
<?php
include_once "ecwid_product_api.php";
$api = new EcwidProductApi(410495); // initialize the API class. Replace 1003 with your Store ID
?>

<div id="meny">
<div id="ecwid-menu">
<?php

$categories 
$api->get_subcategories_by_id($parent_category_id 0); //get product info by its ID
echo '<ul>';

                        foreach(
$categories as $category)
                            {
    echo 
'<li id="parentitem">';
                    
echo <<<EOT

<a href='
{$category["url"]}' style='float: left; width: auto;'>
{$category["name"]}
</a>

EOT;

$subcategories $api->get_subcategories_by_id($category["id"]); //get product info by its ID
if ($subcategories) {
echo 
'<ul id="submenu">';
                        foreach(
$subcategories as $subcategory)
                            {

echo <<<EOT

<li id="subitem"><a href='
{$subcategory["url"]}'>
{$subcategory["name"]}
</a></li>

EOT;

}echo 
'</ul>';
}
echo 
'</li>';

}
echo 
'</ul>';

?>
</div>
</div>
Reply With Quote
  #2  
Old 04-27-2012, 12:55 PM
Matt K's Avatar
Matt K Matt K is online now
Ecwid Team
 
Join Date: Oct 2011
Posts: 4,840
Default

Hello,

At the moment, Ecwid Product API doesn't take into account the categories sort order you've set in your control panel, unfortunately. However, our developers are currently working on it. It wil be released with the next Ecwid version (10.4). Once Ecwid servers get updated, your API requests will return the categories in the order you've set in your control panel.
__________________
Matt K
Ecwid Team

Ecwid Guide for Beginners

Ecwid Help Center

Ecwid video tutorials
Reply With Quote
  #3  
Old 04-27-2012, 01:23 PM
Ejub Bicic @ejubbicic's Avatar
Ejub Bicic @ejubbicic Ejub Bicic @ejubbicic is offline
 
Join Date: May 2011
Location: Sweden
Posts: 12
Default

Thank you for your quick response, looking forward to 10.4!
Reply With Quote
Reply

Tags
api, category, menu links; catergories

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT. The time now is 12:52 AM.
Powered by vBulletin® Version 3.8.6. Copyright ©2000 - 2014, Jelsoft Enterprises Ltd.