[TYPO3-shop] commerce - choosing from multiple parent categories with TS rootline object
Amiran Chyb
amiran.chyb at stopspam.gmail.com
Mon Nov 6 16:29:31 CET 2006
Hi there
I've chosen tx commerce because of flexibility it provides with nested
categories and possibility of multiple parent categories.
Let me explain how I wanted to use this feature, it will be then easier to
explain my problem on a example.
I'm setting up gallery website. Gallery's products will have some 1/2
level categories, like
jewellery
-rings
-product1
-product2
-necklaces
-product3
glass
-product4
additionaly I'd like to browse products by their author (maker). so I've
added additional Authors categories subtree
Authors
-author1
-product1
-product3
-author2
-product2
-author3
-product4
Product Types
-jewellery
-rings
-product1
-product2
-necklaces
-product3
-glass
-product4
with this setup, when I'm adding new product I can set 2 parent categories
for it, one from Product Types subtree, and one from Authors subtree.
On a page, I can have 2 menus: for each subtree (btw. for Product Types
subtree I use regular page structure, and on each page I insert products
categories plugin with appropriate category selected just to have
possibility of using normal page tree menu, since it allows me to get
EXPALL functionality which categories menu lacks at the moment).
And now, to the point:
Depending on which subtree FE user is browsing he will be aware of this
subtree's categories. So, if he's choosing jewellery-rings he will see
product1 and product2, but he won't be able to see authors of those
products (in this case: author1).
To achieve this functionality we would have to use Rootline navigation
which can handle multiple parents.
It would get 2 parameters: current category ID/product ID and a target
root category.
It would then search recursively parent categories of current cat/product
until it would find given Root category ID (in a 2nd parameter). Then, it
would return the UID for this particular path that managed to get bak to
given Root category.
so, for example, in pseudo ts
1 = commerce_rootline
1.rootCategory = 2
given 2 is uid of Authors ccategory and we are on Product
Types-jewellery-rings-product1 page, the function called by rootline would
start searching path beginning by parent categories of current product (in
case of PRODUCT1 it would be 2 parent categories - 'rings' and 'author1'):
product1-rings-jewellery-product types-categories root // no
rootCategory=2 found here
and second one:
product1-author1-authors // authors has UID=2, so the search stops here
and hence it would return: authors-author1-product
from which I could choose with TS only lewvel with AUTHOR1 information and
display it in some TS Object Path field with Templa Voila (or even better,
I could use it inside of product list template, so ich product in a list
would contain additional field 'Author').
Know, let's look at the current implementation.
I've scanned the current navigation code, and this is what I know:
current CommerceRootline function in \lib\class.tx_commerce_navigation.php
already calls:
getCategoryRootlineforTS($this->gpVars['catUid'],$this->category);
this function looks fine for single parent category model, but is unable
to search for multiple parent categories for 2 reasons:
1) as a starting point it chooses gpVars['catUid']. And CatUID gpvar for
currently selected product depends only on our browsing history (which
category were we browsing on a previous page: author1 or rings), so it
doesn't really checks the db for products parent categories. also, it
wouldn't work if we would like to insert this rootline for each product on
a product listing page, since it would use the same CatUID for each of
them (the one from GET vars).
2) getCategoryRootlineforTS doesn't check for parent categories, it just
gets
$CategoryObject->parent_category_uid
so it's just a single parent.
I'm not sure which one parent would show up if we have multiple parents,
but I guess it depends on a way of adding new product (order of parent
categories in commerce module or something like that).
moreover, class.tx_commerce_category which $CategoryObject instantiates
doesn't have getParentCategories() member too.
Actually the equivalent DAO class class.tx_commerce_db_category has this
method ( getParentCategories() ) for retrieving parents from DB, so it
would be trivial to add it to tx_commerce_category.
Then it would be possible to change getCategoryRootlineforTS to search in
a multiple parents paths.
I don't know whether I should start writing it, or choose some other way,
so my questions:
is this feature planned, was it planned briefly in a way I've described it
and is there any other way to achieve it?
even if it would work like that I think it wouldn't be trivial to insert
this parent information to each product in a products list (as opposed to
single product description) - would I have to add to product listing
pluigin/template additional marker which would insert data based on some
additional plugin TS configuration?
thanks a lot
greets
Amiran Chyb
More information about the TYPO3-project-tt-products
mailing list