Issue set product order in admin

Help for integrating the Laravel package
Forum rules
Always add your Laravel, 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: 7917
Joined: 01 Jan 1970, 00:00

Re: Issue set product order in admin

Post by aimeos » 11 Mar 2022, 12:08

Executing that command was only to see if it's cache related. If you can reproduce that it works after changing the product positions, we can see where the problem lies.

There's an "Index" decorator for the backend, which should update the product index each time you change one of the positions:
https://github.com/aimeos/ai-admin-jqad ... /Index.php

Can you check if that decorator is used?
Professional support and custom implementation are available at Aimeos.com
If you like Aimeos, Image give us a star

DmS
Posts: 56
Joined: 09 Aug 2021, 08:59

Re: Issue set product order in admin

Post by DmS » 14 Mar 2022, 07:49

Disregard the above, now it is working without artisan commands.
Tested it multiple times and it works without any other actions than changing it in the admin, Odd that it took so long before it started working, but good :)
_____________
Laravel 8 with Aimeos 2021.10.7 + Marketplace. Setup via composer. Mac with Valet and MySql 8.0.25

DmS
Posts: 56
Joined: 09 Aug 2021, 08:59

Re: Issue set product order in admin

Post by DmS » 31 Mar 2022, 11:43

Again a revisit to this.
As we deployed the aimeos upgrade etc onto the customers stage site, we noticed that the order set in admin did not reflect live.

Tried the

Code: Select all

php artisan aimeos:clear
- did not help.
Added some logging to the decorator that handles rebuild of indexes, it's called and goes into the rebuild call.

Started comparing the db to my local install where it works and found one thing.
Locally where it works, the position is saved in the mshop_index_catalog for both the main site for the category and the sub sites for the category (as mentioned I run marketplace), but on the stage site, position was only updated for the sub-site (1.7) for the main siteid 1. was 0 for all products.

Changed it manually in the db and then the sorting was applied in the shop.
What except for the

Code: Select all

\Aimeos\MShop::create( $context, 'index' )->rebuild( $items );
in the decorator handles indexing of this?*

Note, If I run this

Code: Select all

php artisan aimeos:jobs "index/rebuild index/optimize" saluhall
it rebuilds the indexes properly, but it should rebuild as you save position in admin if I understand you correctly
_____________
Laravel 8 with Aimeos 2021.10.7 + Marketplace. Setup via composer. Mac with Valet and MySql 8.0.25

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

Re: Issue set product order in admin

Post by aimeos » 01 Apr 2022, 12:15

The index is updated by the admin backend at the vendor level but not at parent levels like you've already noticed. You shouldn't build the index at the "default" level but aggregate the index records from the vendors like for the products.
Professional support and custom implementation are available at Aimeos.com
If you like Aimeos, Image give us a star

DmS
Posts: 56
Joined: 09 Aug 2021, 08:59

Re: Issue set product order in admin

Post by DmS » 01 Apr 2022, 12:52

Aha.
How do I go about doing that?
I have the following in my shop.php config

Code: Select all

'mshop' => [
        'locale' => [
            'site' => 'saluhall',
            'manager' => [
                'sitelevel' => 3,
            ],
        ],
        'common' => [
            'manager' => [
                'maxdepth' => 3,
            ],
        ],
    ],
Or is it something completely different I need to do?
/Dan
_____________
Laravel 8 with Aimeos 2021.10.7 + Marketplace. Setup via composer. Mac with Valet and MySql 8.0.25

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

Re: Issue set product order in admin

Post by aimeos » 01 Apr 2022, 16:18

You should not use the the aimeos:jobs command to rebuild the index for the parent site because the index records from the vendor sites should be used instead.
Professional support and custom implementation are available at Aimeos.com
If you like Aimeos, Image give us a star

DmS
Posts: 56
Joined: 09 Aug 2021, 08:59

Re: Issue set product order in admin

Post by DmS » 04 Apr 2022, 12:49

Ok, so you are saying:
"dont' index the parent site, aggregate the vendors index".

But.

If the admin only updates the index for the vendor site as you change position for products in a category, the change is not reflected in the default site where all the purchases are made. Customers don't enter the vendor sites in our setup, those are invisible to the visitor. Everything happens in the default site and products from vendors are displayed in categories in the default site.

The only way I've found to get the sorting change visible in the default site when looking in a category, is to update the index for the default site as well.

So if I I do as you say, and don't run the aimeos:jobs command to rebuild the index for the parent site, the products are not reordered for the visitors. Basically the index records for the vendor sites are not used at all for me.

So when you say:
"you should aggregate the index records from the vendors like for the products"
I might be stupid here, but unfortunately I don't understand how to do that.
/Dan
_____________
Laravel 8 with Aimeos 2021.10.7 + Marketplace. Setup via composer. Mac with Valet and MySql 8.0.25

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

Re: Issue set product order in admin

Post by aimeos » 06 Apr 2022, 09:46

Assume you have the following setup:

"default" site:
- categories

Vendor sites:
- products
- product<->category relations
- index records in mshop_index_catalog

If vendors add products and associate them to categories resp. change the order of the products per category in the Catalog > Category panel, the index records in the mshop_index_* tables are created with the vendor site IDs.

Customers browse at the marketplace using the "default" site and records from the mshop_index_* tables are aggregated to the default site (by default if you use "mshop/locale/manager/sitelevel = 3"). The order of the products at the marketplace is determined by the order of the products from the vendor levels. Products at the vendor level with the same position (e.g. 0) are in random order at the marketplace level, while all products at the vendor level with position 1 are in random order at the marketplace level after those products with position 0.
Professional support and custom implementation are available at Aimeos.com
If you like Aimeos, Image give us a star

DmS
Posts: 56
Joined: 09 Aug 2021, 08:59

Re: Issue set product order in admin

Post by DmS » 07 Apr 2022, 08:12

- Assumed Setup matches mine.
- Vendors working principle as described matches ours. mshop_index_* tables are updated as you describe
- Customers browse at the marketplace using the "default" site. Correct.
and records from the mshop_index_* tables are aggregated to the default site (by default if you use "mshop/locale/manager/sitelevel = 3"). The order of the products at the marketplace is determined by the order of the products from the vendor levels
And this is not happening.
Products are indeed visible in the categories as set by the vendor, but a set order on the vendor level is not applied/aggregated to the default level. It's only visible in admin.
I've tried it many times, including unique positions for each product in a category. It does not work. The only way I get the positions to work is to do what you say I shouldn't, to run

Code: Select all

php artisan aimeos:jobs "index/rebuild index/optimize" saluhall


Checking my config and I have this in there for the mshop:

Code: Select all

'mshop' => [
        'locale' => [
            'site' => 'saluhall',
            'manager' => [
                'sitelevel' => 3,
            ],
        ],
        'common' => [
            'manager' => [
                'maxdepth' => 3,
            ],
        ],
    ],
    
and for jobs I have :

Code: Select all

'locale' => [
        'manager' => [
            'sitelevel' => 3,
        ],
    ],
Per instructions...
_____________
Laravel 8 with Aimeos 2021.10.7 + Marketplace. Setup via composer. Mac with Valet and MySql 8.0.25

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

Re: Issue set product order in admin

Post by aimeos » 12 Apr 2022, 12:16

We've tested the that setup with 2021.10 and the latest version and both behave as expected:

Marketplace:
- catagories
- no products
- no category <-> product relations

Vendor site 1:
- product 1 & 2
- category <-> product relation at position 0 (product 1) and 2 (product 2)

Vendor site 2:
- product 3 & 4
- category <-> product relation at position 1 (product 3) and 3 (product 4)

No index/rebuild job has been executed. The order of the products in the marketplace is:
1.) producct 1
2.) product 3
3.) product 2
4.) product 4

Maybe your problem is that there are already entrires in the mshop_index_* tables from your marketplace site and they overwrite all relations from the vendor sites. To test, truncate the mshop_index_* tables and only run the index/rebuild job for your vendor sites once, i.e.:

Code: Select all

php artisan aimeos:jobs "index/rebuild" "vendor1 vendor2"
Professional support and custom implementation are available at Aimeos.com
If you like Aimeos, Image give us a star

Post Reply