Closed vandres closed 9 months ago
I think, the problem also occurs on Product/VariantQueries like this:
$products = Product::find()
->siteId($shopSite->id)
->hasVariant([
'hasSales' => true,
])
->limit(2)
->orderBy('RAND()')
->all();
It shows products, even there is no sale on that "$shopSite"
Thanks for reporting that! I’ve just fixed it for the next release.
To get the fix early, change your craftcms/commerce
requirement in composer.json to:
"require": {
"craftcms/commerce": "dev-develop#ad6803123e4dbe5127fb7780a9ed650dda27ac29",
"...": "..."
}
Then run composer update
.
We will update you here once the release is out. Thanks.
What happened?
Description
We came across a "bug", where sales were calculated wrongly, on a newly created site.
The product in use, has different active categories per site. Our sales are calculating the promotion based on these categories.
Site Shop EUR: Category EUR -45% Site Shop CHF: Category CHF -45% Site Blog: Category EUR -45%, Category CHF -45%
Now we have a different site, where products are queryied from one of the shop sites. The price, descriptions, categories are all correct. But when I query the sales, it always take that different site. That happens to have both categories. If I disable both categories for that site, there is no promotion at all.
Steps to reproduce
craft.products().siteId(siteA.id).all()
)Expected behavior
Only the sale, enabled for site A should be applied
Actual behavior
Sales from site C are applied
Additional information
I hotfixed
vendor/craftcms/commerce/src/services/Sales.php
, lines 459 and 460. It seems to work. But I am not 100% sure, if it is totally correct.from
to
Craft CMS version
4.5.9
Craft Commerce version
4.3.2 Pro
PHP version
8.2
Operating system and version
CentOS
Database type and version
MariaDB 10.5
Image driver and version
-
Installed plugins and versions