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

[4.x]: Cannot assign null to property exception when trying to save Sale/Promotion on fresh install #3364

Closed
bliswebagency opened this issue Jan 11, 2024 · 2 comments
Labels
bug commerce4 Issues related to Commerce v4

Comments

@bliswebagency
Copy link

bliswebagency commented Jan 11, 2024

What happened?

Description

After a fresh Craft and Commerce 4 install without any other plugins, trying to save a Sale results in cannot assign null to property error

Steps to reproduce

  1. Set up craft and commerce store. Add test product
  2. Create a new Sale setting values: title, description, matching item, effect (eg. reduce by 50%), Enable switched on

Expected behavior

No exception and Sale is saved

Actual behavior

Exception occurs and Sale is not saved

TypeError: Cannot assign null to property craft\commerce\models\Sale::$categoryRelationshipType of type string in /apps/commerce-craft/craft/vendor/craftcms/commerce/src/controllers/SalesController.php:145
Stack trace:
#0 [internal function]: craft\commerce\controllers\SalesController->actionSave()
#1 /apps/commerce-craft/craft/vendor/yiisoft/yii2/base/InlineAction.php(57): call_user_func_array(Array, Array)
#2 /apps/commerce-craft/craft/vendor/yiisoft/yii2/base/Controller.php(178): yii\base\InlineAction->runWithParams(Array)
#3 /apps/commerce-craft/craft/vendor/yiisoft/yii2/base/Module.php(552): yii\base\Controller->runAction('save', Array)
#4 /apps/commerce-craft/craft/vendor/craftcms/cms/src/web/Application.php(305): yii\base\Module->runAction('commerce/sales/...', Array)
#5 /apps/commerce-craft/craft/vendor/craftcms/cms/src/web/Application.php(606): craft\web\Application->runAction('commerce/sales/...', Array)
#6 /apps/commerce-craft/craft/vendor/craftcms/cms/src/web/Application.php(284): craft\web\Application->_processActionRequest(Object(craft\web\Request))
#7 /apps/commerce-craft/craft/vendor/yiisoft/yii2/base/Application.php(384): craft\web\Application->handleRequest(Object(craft\web\Request))
#8 /apps/commerce-craft/craft/web/index.php(12): yii\base\Application->run()
#9 {main}

Craft CMS version

4.6.0

Craft Commerce version

4.3.3

PHP version

8.1.27

Operating system and version

Linux 4.4.0-210-generic

Database type and version

MySQL 5.7.33

Image driver and version

GD 8.1.27

Installed plugins and versions

Commerce 4.3.3 and nothing else

@bliswebagency bliswebagency added commerce4 Issues related to Commerce v4 bug labels Jan 11, 2024
nfourtythree added a commit that referenced this issue Jan 12, 2024
@lukeholder
Copy link
Member

lukeholder commented Jan 12, 2024

Thanks for reporting this. It also affects discounts, and we will fix them both shortly and let you know once the hotfix release is out.

@lukeholder
Copy link
Member

This is fixed in Commerce 4.4.1.1

Thanks!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug commerce4 Issues related to Commerce v4
Projects
None yet
Development

No branches or pull requests

2 participants