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!
DmS
Posts: 56
Joined: 09 Aug 2021, 08:59

Issue set product order in admin

Post by DmS » 15 Feb 2022, 11:16

Hi.
In admin, I want to set a default order of products in a category. Basically control which products should be on top for the customer by default.

If I understand it correctly, this should be done by going into Catalog->Categories, select a category, go to the tab "Products"
Then you should be able to set display order by changing the numbers in the Position column, correct?

When I do this, i encounter some oddities.
First, if I change the position value (all is 0 by default) to 1 or -1 the reference to the product disappears from the listing leaving me with just an "eye-icon" instead of product data. The link from the icon also lacks the product id. Using the edit pen, I can see a list of products, but I can't assign it. It says "data saved successfully" but no product data is set.
Looking at the catalog -> products the edited product is still there without changes.

Am I doing something wrong, or is there something else going on here?

In the log i'm getting an integrity costraint violation when I change a value and get an error saving data:

Code: Select all

SQLSTATE[23000]: Integrity constraint violation: 1062 Duplicate entry '8-product-1.2.-default-' for key 'mshop_catalog_list.unq_mscatli_pid_dm_sid_ty_rid':
UPDATE "mshop_catalog_list"
SET
"parentid" = ?, "key" = ?, "type" = ?, "domain" = ?, "refid" = ?, "start" = ?,
"end" = ?, "config" = ?, "pos" = ?, "status" = ?, "mtime" = ?, "editor" = ?
WHERE "siteid" = ? AND "id" = ?
["8","product|default|","default","product","",null,null,"[]",1,1,"2022-02-16 10:59:32","Dev Pigment","1.2.","110"]
And the product I'm changing position for in mshop_catalog_list looks like this in the db:

Code: Select all

id	parentid	siteid	key	type	domain	refid	start	end	config	pos	status	mtime	ctime	editor
110	8	1.2.	product|default|75	default	product	75			[]	0	1	2021-09-30 09:49:07	2021-09-30 09:49:07	sadmin@dinsaluhall.se
Screenshot 2022-02-15 at 12.06.05.png
Screenshot 2022-02-15 at 12.06.05.png (179.77 KiB) Viewed 2079 times
_____________
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 » 16 Feb 2022, 13:40

Please update to the latest 2021.10 LTS version as the problem is fixed there.
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 » 25 Feb 2022, 08:36

Ok, we've updated and now we can change the order in admin, but it's not reflected towards the customer which is what we expected. The product order is still the same in the category.
_____________
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 » 26 Feb 2022, 07:52

Did you set the position value to an unique integer for each entry?
Did you try to clear the cache using:

Code: Select all

php artisan aimeos:cache
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 » 28 Feb 2022, 09:14

I set the integer value on some of the entries, based on the client saying they want to be able to place 3-4 products at the top and don't care about the rest. Do I need to have all products in the category as unique integers?

Cache cleared of course, both aimeos and browser
_____________
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 Mar 2022, 09:04

By default, all products get position "0" and if you change a few products to position 1, 2, 3 and 4, the rest still remains at position zero and the database will return them first. Thus, you have to set all positions to non-zero but they don't have to be unique.
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 Mar 2022, 10:00

Ok, I'll try that.
Was a bit odd that I saw absolutely no effect at all after setting non-zero to some products, I expected the changed ones to move in relation to the 0 ones.
Thank you
_____________
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 » 09 Mar 2022, 11:42

Back at this.
Images shows how I've ordered things in admin, and the result I got.
Note that the product " "0" mjöl till pizza, 1kg" is originally first in the list, and I've positioned it as #2 in admin, still it shows as #1 in the frontend.

Note that I'm using marketplace if that will make a difference, I can only add the product order in the category if I'm in the site that owns the products. I can't set the order from the top level site.
Looking in the mshop_catalog_index i see that the sort order is set for site 1.2 and for 1. it is 0 on all products in the category.
Switching to the other site in the url still gives the same order without position applied.

Intended sort:
Intended sort order
Intended sort order
sort admin.jpg (138.5 KiB) Viewed 1882 times
Resulting sort in frontend:
what I got in the frontend
what I got in the frontend
sort frontend.jpg (221.91 KiB) Viewed 1882 times
This is after updating to latest release.
Tried php artisan optimize:clear as well, made no difference.
_____________
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 » 11 Mar 2022, 07:15

Does executing this command help?

Code: Select all

php artisan aimeos:clear
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 » 11 Mar 2022, 11:21

I had tried that and multiple other variants of clearing caches.
Now a couple of days after it worked.

But should I really have to do that each time I change product order?
That would not work at all once the shop is delivered to the customer, they are non technical, but constantly adjusts product orders to push what they want sold from week to week.

There is no way we can allow them onto the server to run commands like this!
How much performance hit would it be to add this as a cron job that runs once an hour or so?
/Dan
_____________
Laravel 8 with Aimeos 2021.10.7 + Marketplace. Setup via composer. Mac with Valet and MySql 8.0.25

Post Reply