Feature: Suppliers (extra fields / translations)

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
aimeos
Administrator
Posts: 7836
Joined: 01 Jan 1970, 00:00

Re: Feature: Suppliers (extra fields / translations)

Post by aimeos » 12 Aug 2015, 12:44

Yvler wrote: What is the best way to link these items to a supplier (mshop_supplier)? Via the list tables of the the items itself (mshop_text_list, mshop_attribute_list, mshop_media_list) or add an extra list table to suppliers (mshop_supplier_list)?
The best way is to create a mshop_supplier_list table and a corresponding manager like described in one of the former posts. Than you can link to all other items you need and retrieve them with a single call to searchItems(). Doing it the other way round would be far more difficult in terms of collecting the data.
Yvler wrote: As a result of this, we would like to generate a list (like the categories listing) on the front end with products of a specific supplier, with the supplier logo and description on top of the listing :). (how do we extend this?)
In this case I would link the products to the suppliers via the new mshop_supplier_list table just like the catalog domain does. Then you can create a new "catalog supplier" component that works very similar to the catalog list component or its "promo" resp. "head" subpart: https://aimeos.org/docs/Developers/Html ... components
To get all suppliers for a product in the detail view, you then need to search for "supplier.list.refid"=<productid> and "supplier.list.domain"='product'. If you implement it like this, we would love to integrate your changes into the Aimeos core, so your application can be upgraded any time later without changes :-)

You could also do it the other way round, i.e. link suppliers to the products via the mshop_product_list table and get all products for a specific supplier by searching for "product.list.refid"=<supplierid> and "product.list.domain"='supplier'. The downside is that this would put a lot of pressure on the mshop_product_list table for large amounts of products which MySQL won't cope well, so we would try to avoid this at any cost in the official code.

Yvler
Posts: 33
Joined: 04 Jun 2015, 10:15

Re: Feature: Suppliers (extra fields / translations)

Post by Yvler » 13 Aug 2015, 12:45

Sooo, we should do it the other way around.
The way we're now using the suppliers, via the product_list table, is not the best way to go?

But don't we have the problem, if we go the other way, that we can't get the supplier as easily as we do now?
We still need to show the supplier on the detail page and in our admin with all the items :)

Is it that big of a deal with performance if we keep it the way it is and put the extra info of the supplier itself in the supplier_list table? Maybe cache the supplier pages with the listing of the products or...?
or maybe even have duplicate data in the products_list table and supplier_list table?

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

Re: Feature: Suppliers (extra fields / translations)

Post by aimeos » 13 Aug 2015, 13:32

Yvler wrote:Sooo, we should do it the other way around.
The way we're now using the suppliers, via the product_list table, is not the best way to go?
That depends on the requirements but from a ease of use and performance perspective I would say "no". I will explain in detail below.
Yvler wrote: But don't we have the problem, if we go the other way, that we can't get the supplier as easily as we do now?
We still need to show the supplier on the detail page and in our admin with all the items :)
In the detail page its not a problem at all to show the supplier information as you have to use the supplier manager to load the complete supplier details nevertheless. This is in fact even easier when your products are attached to the mshop_supplier_list table because you can load all supplier data with only one searchItems() call :

Code: Select all

$manager = MShop_Factory::createManager( $context, 'supplier' );
$search = $manager->createSearch( true );
$expr = array(
    $search->compare( '==', 'supplier.list.refid', <prodid> ),
    $search->compare( '==', 'supplier.list.domain', 'product' ),
    $search->getConditions(),
);
$search->setConditions( $search->combine( '&&', $expr ) );
$supplierItems = $manager->searchItems( $search, array( 'text', 'media' ) );
If you attach suppliers to products instead, you will have to loop over all supplier items and call searchItem() of the supplier manager afterwards, which needs at least one more SELECT statement.
Yvler wrote:Is it that big of a deal with performance if we keep it the way it is and put the extra info of the supplier itself in the supplier_list table? Maybe cache the supplier pages with the listing of the products or...?
or maybe even have duplicate data in the products_list table and supplier_list table?
As far as I remember, you want to show the supplier name also in the catalog list view. If it's only the name, I would recommend to attach the supplier name (in each language) also to the product via the mshop_product_list table. That saves you from loading the supplier items as well, will be much faster and even easier to output the names afterwards.

You could also to an automatic cross linking (suppliers to products and product to suppliers) in your admin interface if you need the supplier items in the catalog list view nevertheless. The downside is that you have redundant information that may get out of sync.

So my recommendation based on the current information would be:
- Attach the supplier names via the mshop_product_list table for your catalog list view
- Add texts, media, products, etc. to the supplier via your new mshop_supplier_list table
- Retrieve the supplier data in your "supplier" subpart in the catalog detail view with the code above
- Create a catalog supplier component similar to the catalog list/promo subpart for the product list by supplier

That will be the easiest way to retrieve the informations you need in all components and does scale very well. All other ways have downsides regarding ease of use and performance.

Yvler
Posts: 33
Joined: 04 Jun 2015, 10:15

Re: Feature: Suppliers (extra fields / translations)

Post by Yvler » 18 Aug 2015, 07:37

Hi

I've created the list files for supplier.. but when adding a list item to the supplier list I get this error:
'Number of binds (13) doesn't match the number of markers in "mshop/supplier/manager/list/default/item/insert"'

What am I doing wrong?
Attachments
List.zip
List supplier manager
(9.99 KiB) Downloaded 280 times

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

Re: Feature: Suppliers (extra fields / translations)

Post by aimeos » 18 Aug 2015, 08:16

Yvler wrote: I've created the list files for supplier.. but when adding a list item to the supplier list I get this error:
'Number of binds (13) doesn't match the number of markers in "mshop/supplier/manager/list/default/item/insert"'
Your configuration file for the supplier list manager isn't found in "./lib/mshoplib/config/common/mshop/supplier/manager/list/default.php" (if you added it to the core, in extensions it's "./lib/custom/..."). Maybe the file doesn't exist or it doesn't contain the configuration like this:

Code: Select all

return array(
    'item' => array(
        'insert' => 'INSERT INTO ...',
    ),
);

Yvler
Posts: 33
Joined: 04 Jun 2015, 10:15

Re: Feature: Suppliers (extra fields / translations)

Post by Yvler » 18 Aug 2015, 11:48

Got it!

I've got the complete supplier_list & supplier_list_type working..
how do I do a Git core commit to commit all these files? :) haven't done that before

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

Re: Feature: Suppliers (extra fields / translations)

Post by aimeos » 18 Aug 2015, 12:16

Yvler wrote: I've got the complete supplier_list & supplier_list_type working..
how do I do a Git core commit to commit all these files? :) haven't done that before
Really great! :-)
There's some documentation available for working with Git/GitHub: https://aimeos.org/docs/Developers/Git_workflow

Yvler
Posts: 33
Joined: 04 Jun 2015, 10:15

Re: Feature: Suppliers (extra fields / translations)

Post by Yvler » 24 Aug 2015, 14:29

Hi

I did some core updates today, but there's still something I can't get working :)
I updated the manager/item files to have the getRefItems() function.. but it's not working.. I have rows in the list table, but get no results when using the getRefItems or getListItems on the list manager of supplier

What have I missed?

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

Re: Feature: Suppliers (extra fields / translations)

Post by aimeos » 24 Aug 2015, 14:44

Yvler wrote: I updated the manager/item files to have the getRefItems() function.. but it's not working.. I have rows in the list table, but get no results when using the getRefItems or getListItems on the list manager of supplier

What have I missed?
I think this line at the end of searchItems() in the supplier manager is missing:

Code: Select all

return $this->_buildItems( $map, $ref, 'supplier' );
It's responsible for fetching the list items and referenced items and adding them to the supplier item.

Yvler
Posts: 33
Joined: 04 Jun 2015, 10:15

Re: Feature: Suppliers (extra fields / translations)

Post by Yvler » 24 Aug 2015, 15:01

Mm Weird

I committed this to the core last week..
I will do another core commit within a few minutes :)

Post Reply