Search the Community
Showing results for tags 'group items'.
-
Hello for all, sorry for this topic title but let me try to explain. Website has product items, where sometimes products go to "Outlet" (actions/discounts). Main part here is that in "action" status: a) product can have new price and go alone to discount OR b) product is in group with other products ("collection", and new price is only valid in case when customer buy full collection). First problem was how to get this : Product items: A on action B on action in group with "D" C on action D on action in group with "B" --------------------------------------------------- Outlet list page need to show 3 items: 1. item (A) 2. item (B, D) (eg. item image is "TV+sofa") 3. item (C) First what I done, was that I created Outlet "category" with children, where children page has fields: title, group image and page select field (to select products from another page tree). But that was wrong and dirty (few foreach, pagination..., etc. that was bad concept). Than I decided to place page select field on product item, and from product item select it's group (single select field). And that was ok, and I like it also because administration in any variant need to go to product to set new price. Right now, administration first create group page with some title and with some image. After that, go to product item, check field "action", write new price, and - if - product is part of group - add - it to group. There is part of code on "Outlet" list page: // outlet-list.php // $items: single items // outlet: page field, it's parent is "Outlet" list page $items = $pages->find('template=product-item, action=1, outlet.count=0'); // outlet=0 or outlet=''... $group_items = $pages->find('template=product-item, action=1, outlet.count>0'); // group items ("merge") foreach( $page->children() as $group ){ // go through Outlet children ("group id pages") if($group_items->has("outlet=$group->id")){ // if in array are items with that group id $group->singles = $group_items->find("outlet=$group->id"); // append to page "group" new attribute and fill it $items->add($group); // now go back and append to "items" new type of "item" } } // pagination $pagination = $items->renderPager(); After it in rendering process I get basic product items, and "group" items together inside list page. Here is the problem: When I go and set some of Group page as "unpublished", I expect, after it, to get that group subitems shows as alone (singles) inside Outlet. But not. They doesn't shows!? In that case outlet.count return null, but real "singles" return false. I try more options with selector (and different page select field types) but can't get what expect to be. // selector to return singles 'template=product-item, action=1, outlet.count=0' // tried options outlet=0, outlet='', outlet=0|"", outlet.count<1 etc... Sorry for this long, long topic. If someone has some idea what and where... I would be grateful Best regards! p.s. if all this is confused, last sleeping was... can't remember