Fixed: Sort by price in module catelog page
This commit is contained in:
@@ -35,11 +35,12 @@
|
||||
{/if}
|
||||
</p>
|
||||
<div class="panel-action clearfix">
|
||||
<span class="module-price">{if isset($element->price)}{if $element->price|floatval == 0}{l s='Free'}{else}{$element->price_formatted}{/if}{/if}</span>
|
||||
{if isset($element->type) && $element->type == 'addonsMustHave' && !$element->not_on_disk}<span class="label label-primary">{l s='In library'}</span>{/if}
|
||||
{if isset($element->type) && $element->type == 'addonsMustHave' && $element->not_on_disk}
|
||||
<span class="module-price">{if isset($element->price)}{if $element->price|floatval == 0}{l s='Free'}{elseif isset($element->id_currency)}{displayPrice price=$element->price currency=$element->id_currency}{/if}{/if}</span>
|
||||
<a class="btn button-action pull-right btn-primary _blank" href="{$element->addons_buy_url|replace:' ':'+'|escape:'html':'UTF-8'}">{l s='Explore'}</a>
|
||||
{else}
|
||||
<a class="btn button-action pull-right btn-primary{if !$element->trusted} untrustedaddon{/if}" {if !$element->trusted} data-target="#moduleNotTrusted" data-toggle="modal"{/if} data-link="{$element->options.install_url|escape:'html':'UTF-8'}" data-module-display-name="{$element->displayName|escape:'html':'UTF-8'}" data-module-name="{$element->name|escape:'html':'UTF-8'}" data-module-image="{if isset($element->image)}{$element->image}{else}{$modules_uri}/{$element->name}/{$element->logo}{/if}" data-author-name="{$element->author|escape:'html':'UTF-8'}" data-author-uri="{if isset($element->author_uri)}{$element->author_uri|escape:'html':'UTF-8'}{/if}" href="{if !$element->trusted}#{else}{$element->options.install_url|escape:'html':'UTF-8'}{/if}" title="{l s='Install'}">{l s='Install'}</a>
|
||||
<a class="btn button-action pull-right btn-primary{if !$element->trusted} untrustedaddon{/if}" {if !$element->trusted} data-target="#moduleNotTrusted" data-toggle="modal"{/if} data-link="{$element->options.install_url|escape:'html':'UTF-8'}" data-module-display-name="{$element->displayName|escape:'html':'UTF-8'}" data-module-name="{$element->name|escape:'html':'UTF-8'}" data-module-image="{if isset($element->image)}{$element->image}{else}{$modules_uri}/{$element->name}/{$element->logo}{/if}" data-author-name="{$element->author|escape:'html':'UTF-8'}" data-author-uri="{if isset($element->author_uri)}{$element->author_uri|escape:'html':'UTF-8'}{/if}" href="{if !$element->trusted}#{else}{$element->options.install_url|escape:'html':'UTF-8'}{/if}" title="{l s='Install'}">{l s='Install'}</a>
|
||||
{/if}
|
||||
</div>
|
||||
</div>
|
||||
|
||||
@@ -1665,17 +1665,9 @@ abstract class ModuleCore
|
||||
if ($item->type == 'addonsMustHave') {
|
||||
$item->addons_buy_url = strip_tags((string)$modaddons->url);
|
||||
$prices = (array)$modaddons->price;
|
||||
$id_default_currency = Configuration::get('PS_CURRENCY_DEFAULT');
|
||||
|
||||
foreach ($prices as $currency => $price) {
|
||||
if ($id_currency = Currency::getIdByIsoCode($currency)) {
|
||||
$item->price = (float)$price;
|
||||
$item->id_currency = (int)$id_currency;
|
||||
|
||||
if ($id_default_currency == $id_currency) {
|
||||
break;
|
||||
}
|
||||
}
|
||||
foreach ($prices as $key => $value) {
|
||||
$item->{$key} = $value;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -256,15 +256,23 @@ class AdminModulesCatalogControllerCore extends AdminController
|
||||
if ($criteria == 'name') {
|
||||
return strnatcasecmp($a->displayName, $b->displayName);
|
||||
} else if ($criteria == 'price_increasing') {
|
||||
if (isset($a->price) && isset($b->price))
|
||||
return $a->price > $b->price;
|
||||
else if (isset($b->price) && $b->price)
|
||||
return true;
|
||||
$priceA = $priceB = 0;
|
||||
if (isset($a->price)) {
|
||||
$priceA = $a->price;
|
||||
}
|
||||
if (isset($b->price)) {
|
||||
$priceB = $b->price;
|
||||
}
|
||||
return $priceA > $priceB;
|
||||
} else if ($criteria == 'price_decreasing') {
|
||||
if (isset($a->price) && isset($b->price))
|
||||
return $a->price < $b->price;
|
||||
else if (isset($b->price) && $b->price)
|
||||
return true;
|
||||
$priceA = $priceB = 0;
|
||||
if (isset($a->price)) {
|
||||
$priceA = $a->price;
|
||||
}
|
||||
if (isset($b->price)) {
|
||||
$priceB = $b->price;
|
||||
}
|
||||
return $priceA < $priceB;
|
||||
}
|
||||
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user