Attribute and Sorting

How to configure and adapt Aimeos based shops as developer
Forum rules
Always add your Aimeos and PHP version as well as your environment (Linux/Mac/Win)
Spam and unrelated posts will be removed immediately!
User avatar
Metalics
Advanced
Posts: 103
Joined: 13 Jul 2015, 23:59

Attribute and Sorting

Post by Metalics » 27 Aug 2015, 19:07

Hi to all,
I have more than one question again:)

1- Our website will have dozens of attribute types. Our attribute list is in the left column and it seems boring to see all attribute types in every catalog. I want it to show only the attribute types and attribute items which has at least one product, and remove the ones which are empty. I mean i don't want our customers to see irrelevant attribute types and items when they are displaying a category.
Can that be solved through " <?php if( !empty" or "<?php if( count" property?

2- I still don't understand how the price module works. Under Local>Currency tab I actived 4 different currencies (EUR, GBP, TRY and USD). Again under Local>List tab, i assigned Turkish and English language to each of these currencies. So i have 4 different currency type for both English and Turkish pages.
We don't need to show different currencies for a product, so that we are not using currency selector. But for example; we want to show some products in €, some products in $, some products in TRY etc. I tried but it only shows the first currency the list. Am i asking so much?

3-We have nested catalog list as product categories and have products only in the last catalogs. When displaying parent catalogs, it shows only category texts and images as they have no product assigned. Is it possible to display only 1 level subcategory list in a category under text field?

4-Is it possible to sort product list by date added --from newest to oldest-- ?

Thank you.

User avatar
aimeos
Administrator
Posts: 7835
Joined: 01 Jan 1970, 00:00

Re: Attribute and Sorting

Post by aimeos » 29 Aug 2015, 22:47

Metalics wrote:I have more than one question again:)
OK, one after another :-)
Metalics wrote: 1- Our website will have dozens of attribute types. Our attribute list is in the left column and it seems boring to see all attribute types in every catalog. I want it to show only the attribute types and attribute items which has at least one product, and remove the ones which are empty. I mean i don't want our customers to see irrelevant attribute types and items when they are displaying a category.
Can that be solved through " <?php if( !empty" or "<?php if( count" property?
That's a bit more difficult. You can hide all attributes that have no product count via CSS. For this, you have to overwrite the catalog/filter-tree template to add a CSS class that hides all attributes by default and in the catalog/count template to remove that CSS class again if products have been found.

User avatar
aimeos
Administrator
Posts: 7835
Joined: 01 Jan 1970, 00:00

Re: Attribute and Sorting

Post by aimeos » 29 Aug 2015, 22:57

Metalics wrote: 2- I still don't understand how the price module works. Under Local>Currency tab I actived 4 different currencies (EUR, GBP, TRY and USD). Again under Local>List tab, i assigned Turkish and English language to each of these currencies. So i have 4 different currency type for both English and Turkish pages.
We don't need to show different currencies for a product, so that we are not using currency selector. But for example; we want to show some products in €, some products in $, some products in TRY etc. I tried but it only shows the first currency the list.
You can't mix currencies within the same view and especially not in the basket afterwards! The currency depends on the chosen one - either by the user or configured for the page. If you don't have a currency selector, the first entry in the locale list for the chosen language is used like you've observed. Without currency selector, there will be no way to display the other currencies and then all are shown in EUR, all in GBP, all in TRY or all in USD provided you have assigned prices in that currencies to your products.

User avatar
aimeos
Administrator
Posts: 7835
Joined: 01 Jan 1970, 00:00

Re: Attribute and Sorting

Post by aimeos » 29 Aug 2015, 23:00

Metalics wrote: 3-We have nested catalog list as product categories and have products only in the last catalogs. When displaying parent catalogs, it shows only category texts and images as they have no product assigned. Is it possible to display only 1 level subcategory list in a category under text field?
I'm still unsure what you want to achieve. Do you want to display the products of the subcategories also in the parent category?

User avatar
aimeos
Administrator
Posts: 7835
Joined: 01 Jan 1970, 00:00

Re: Attribute and Sorting

Post by aimeos » 29 Aug 2015, 23:02

Metalics wrote: 4-Is it possible to sort product list by date added --from newest to oldest-- ?
Not automatically but you can easily achieve this by assigning the newest products first to the category in the "catalog -> product" tab instead of adding them to the end.

User avatar
Metalics
Advanced
Posts: 103
Joined: 13 Jul 2015, 23:59

Re: Attribute and Sorting

Post by Metalics » 30 Aug 2015, 01:37

"I'm still unsure what you want to achieve. Do you want to display the products of the subcategories also in the parent category?"

No no. I have a catalog-filter-tree plugin in Catalog list page. Its in the left column and working as product groups. Its ok, i have no problem with it. But i want to add the catalog-filter-tree plugin second time again in the same page (Catalog list page) in the middle column to show only subcatagories of the current category.
But im afraid i ll have to solve this problem with CSS method you suggested for hiding unused attribute types.

Anyways. I am enjoying to build our website with Aimeos. Thank you so much again for this flexible extension.
Cheers!

User avatar
aimeos
Administrator
Posts: 7835
Joined: 01 Jan 1970, 00:00

Re: Attribute and Sorting

Post by aimeos » 30 Aug 2015, 08:35

Metalics wrote: No no. I have a catalog-filter-tree plugin in Catalog list page. Its in the left column and working as product groups. Its ok, i have no problem with it. But i want to add the catalog-filter-tree plugin second time again in the same page (Catalog list page) in the middle column to show only subcatagories of the current category.
But im afraid i ll have to solve this problem with CSS method you suggested for hiding unused attribute types.
Now I understand :-)
The best way would be to create a new subpart for the catalog list component (e.g. catalog/list/tree) that displays the current sub-categories. It's pretty simply as the additional code besides the skeleton listed in the docs for the _setViewParams() method is only:

Code: Select all

$controller = Controller_Frontend_Factory::createController( $this->_getContext(), 'catalog' );
$view->treeNodes = $controller->getCatalogTree( $view->param( 'f_catid' ), array( 'text', 'media' ), MW_Tree_Manager_Abstract::LEVEL_LIST );
More documentation is available here: https://aimeos.org/docs/Developers/Html ... w_subparts

User avatar
Metalics
Advanced
Posts: 103
Joined: 13 Jul 2015, 23:59

Re: Attribute and Sorting

Post by Metalics » 01 Sep 2015, 04:59

Hi again,
For hiding the attributes which have no product, i tried the method you described.
For that i wrapped attribute list by <div class="remove"> </div> class in /catalog/filter/attribute-body-default.html. And i got this:

<fieldset class="attr-<?php echo $enc->attr( $attrType, $enc::TAINT, '-' ); ?>">
<div class="hide">
<legend><?php echo $enc->html( $this->translate( 'client/html/code', $attrType ), $enc::TRUST ); ?></legend>
<ul class="attr-list"><!--
<?php foreach( $attributes as $id => $attribute ) : ?>
--><li class="attr-item" data-id="<?php echo $enc->attr( $id ); ?>">
<input class="attr-item" id="attr-<?php echo $enc->attr( $id ); ?>" name="<?php echo $enc->attr( $this->formparam( array( 'f_attrid', $id ) ) ); ?>" type="checkbox" value="<?php echo $enc->attr( $attribute->getName( 'url' ) ); ?>" <?php echo ( isset( $attrIds[$id] ) ? 'checked="checked"' : '' ); ?> />
<label class="attr-name" for="attr-<?php echo $enc->attr( $id ); ?>"><!--
--><div class="media-list"><!--
<?php
foreach( $attribute->getListItems( 'media', 'icon' ) as $listItem )
{
if( ( $item = $listItem->getRefItem() ) !== null ) {
echo '-->' . $this->media( $item, $contentUrl, array( 'class' => 'media-item' ) ) . '<!--';
}
}
?>
--></div>
<span><?php echo $enc->html( $attribute->getName(), $enc::TRUST ); ?></span><!--
--></label>
</li><!--
<?php endforeach; ?>
--></ul>
</div>
</fieldset>

The class i added is ".hide{display: none;}" in related css file. So i hide all attributes by default in this way. Please can you tell me which code i should add in /catalog/count/attribute-body-default.html file to remove this class for the attributes which have at least one product?

User avatar
aimeos
Administrator
Posts: 7835
Joined: 01 Jan 1970, 00:00

Re: Attribute and Sorting

Post by aimeos » 01 Sep 2015, 08:30

Metalics wrote:Hi again,
For hiding the attributes which have no product, i tried the method you described.
For that i wrapped attribute list by <div class="remove"> </div> class in /catalog/filter/attribute-body-default.html.

The class i added is ".hide{display: none;}" in related css file. So i hide all attributes by default in this way. Please can you tell me which code i should add in /catalog/count/attribute-body-default.html file to remove this class for the attributes which have at least one product?
I don't think you need to change the "/catalog/filter/attribute-body-default.html" template. Simply add "display: none;" to the ".catalog-filter-attribute li.attr-item" in your CSS. In the "/catalog/count/attribute-body-default.html" body template, you have to add one line:

Code: Select all

if( attributeCounts[itemId] ) {
	$(this).removeClass( 'hide' ); // <= this will display list items with counts
	var node = document.createElement( 'span' );
	node.appendChild( document.createTextNode( attributeCounts[itemId] ) );
	$(node).addClass( 'attr-count' );
	return node;
}

User avatar
Metalics
Advanced
Posts: 103
Joined: 13 Jul 2015, 23:59

Re: Attribute and Sorting

Post by Metalics » 02 Sep 2015, 23:38

Hi again,
First of all, thank you for your kind help.

To display the current sub-categories in product list page, i followed your method and added a new subpart with name Submenu. (catalog/list/submenu)

- I added a new folder with name Submenu inside /client/html/src/Client/Html/Catalog/List
- I edited the Default.php file in this directory as: private $_subPartNames = array( 'head', 'submenu', 'quote', 'promo', 'pagination', 'items', 'pagination' );
- I added a Default.php file in the new "Submenu" folder and added your code > You can see HERE
- I added 2 files in /client/html/layouts/catalog/list with name submenu-body-default.html and submenu-header-default.html. You can see submenu-header-default.html HERE and submenu-body-default.html HERE submenu-body-default.html file HERE.

But i still can not see current subcategories in catalog list page. Am i missing anything? Can you please advice?

Post Reply