Page 1 of 1

Sort alphabetically in product hierarchy

Posted: Sun Oct 27, 2013 4:53 pm
by tne
Hello!
I need to sort alphabetically product hierarchy. Output pattern is:

Code: Select all

{if !isset($hdepth) && isset($hierarchy_item)}
<h3>Hierarchy Data for {$hierarchy_item.name} ({$hierarchy_item.id})</h3>
{/if}

{if !isset($hdepth)}{assign var='hdepth' value='0'}{/if}
{foreach from=$hierdata key='key' item='item'}
{strip}

<div id="aa" onclick="switchDisplay('{$item.name}')">
 {if isset($active_hierarchy) and $item.id == $active_hierarchy} class="active"{/if}


  {if $item.count gt 0}
    <a href="{$item.url}" class='katalog_link'>{$item.name}</a>
  {else}
    {$item.name}
  {/if}</div>
  

  {if isset($item.children) }

<div class='left_kataloog_otstup' id="{$item.name}" style="width:180px;display:none;font-size: 14px;">

  {include file=$smarty.template hierdata=$item.children hdepth=$hdepth+1}

</div>

  {/if}
  
 
{/strip}
{/foreach}

How to make it displayed in alphabetical order?

Re: Sort alphabetically in product hierarchy

Posted: Sun Oct 27, 2013 4:59 pm
by Rolf

Re: Sort alphabetically in product hierarchy

Posted: Sun Oct 27, 2013 5:10 pm
by tne
How to apply it to my case?

Code: Select all

{foreach from=$hierdata|sort_array key='key' item='item'}
Tried it, did not work. Help please, I'm not a programmer

Re: Sort alphabetically in product hierarchy

Posted: Sun Oct 27, 2013 5:22 pm
by tne

Code: Select all

{foreach from=$hierdata|sort_array item='item'}
{$item}
{/foreach}
issues

Code: Select all

Каталог товаров: 

 Array Array Array Array Array Array Array Array Array Array Array Array Array Array Array Array Array Array Array Array Array Array Array Array Array Array Array Array Array Array Array Array Array Array

Re: Sort alphabetically in product hierarchy

Posted: Sun Oct 27, 2013 5:27 pm
by Rolf
ohw uhh wait...
Why not use sort parameters in the Products tag? Read module help for more info.

Re: Sort alphabetically in product hierarchy

Posted: Sun Oct 27, 2013 5:31 pm
by tne

Code: Select all

{Products action="hierarchy" sortorder="asc" pagelimit="10"}
does not work
I have tried 100 variations, but nothing earned
Tell me how to apply your modifier.sort_array.php for this case?

Re: Sort alphabetically in product hierarchy

Posted: Mon Oct 28, 2013 12:02 am
by paulbaker
I don't use hierarchy in Products, but I do sort successfully using sortby="[FieldName]". It looks like you are specifying sortorder (up or down) but forgetting sortby?

From Products help:
(optional) sortby="product_name" - Applicable in the summary, categorylist or search actions, this parameter determines the sorting of the output. Possible values are:
item_name
id -- The item id
weight -- The item weight
price -- The item base price
status -- Draft or published
random -- Display in random order on each request
created -- The creation date for this company record
modified -- The modified date for this company record
f:fieldname -- Allows sorting by values of custom fields.

The category list view supports only a few specific sorting options:
id -- The category id.
name -- The category name.

(optional) sortorder="asc" - Specify the order of sorted fields in summary (including after a search) view. Possible values are:
asc -- Ascending order
desc -- Descending order