Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[5.x]: ->hasVariant(['hasStock' => true]) throws a DB error of Unknown column 'purchasables_stores.hasUnlimitedStock' #3505

Closed
sunscreem opened this issue May 18, 2024 · 4 comments

Comments

@sunscreem
Copy link

What happened?

Description

When running the following query:

\craft\commerce\elements\Product::find()->status(Product::STATUS_ENABLED)->hasVariant(['hasStock' => true])->all()

The following error is thrown:

SQLSTATE[42S22]: Column not found: 1054 Unknown column 'purchasables_stores.hasUnlimitedStock' in 'where clause'
The SQL being executed was: SELECT COUNT(*)
FROM `elements` `elements`
[rest of query]

Steps to reproduce

  1. Clean install Craft 5 & Craft Commerce.
  2. Create somewhere to run the above code (I used a module)
  3. Run the query above.

Expected behavior

Return an array of "in stock" products.

Actual behavior

Throws the above error.

Craft CMS version

5.1.4

Craft Commerce version

5.0.6

PHP version

8.2

Operating system and version

No response

Database type and version

mysql

Image driver and version

No response

Installed plugins and versions

  • none
@lukeholder
Copy link
Member

Thanks for reporting this!

We have fixed the error.

To get the fix early, change your craftcms/commerce requirement in composer.json to:

"require": {
  "craftcms/commerce": "5.x-dev#5348e43b58a9ee2b0335de999337bdb9cdbeff68 as 5.0.6",
  "...": "..."
}

Then run composer update.

We will update this ticket once the next release is out.

Thanks!

@sunscreem
Copy link
Author

@lukeholder Thank you - That's it working with the fix.

@lukeholder
Copy link
Member

5.0.7 is now out with this fix! Thanks.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants