Craft Commerce auto-complete broken (again?)
Closed this issue · 10 comments
Describe the bug
Similar to this issue: #6
craft.commerce
craft.orders
craft.products
None are autocompleted or recognized.
Versions
- Plugin version: 1.10.1
- Craft version: 4.2.7
btw I think it should be:
craft.commerce
craft.commerce.products
craft.commerce.orders
Hi Andrew,
The commerce annotation is in the file as expected. Is there anything else that could be wrong?
PS: The official docs also use craft.orders()
and craft.products()
I guess they are the same as craft.commerce.orders
.
Are you still having issues with this?
Unfortunately yes.
To be clear, you're saying this doesn't autocomplete:
craft.orders
craft.products
...but this does?
craft.commerce
craft.commerce.orders
craft.commerce.products
?
If the answer is that neither autocomplete, please go to Preferences -> Symfony and ensure Enable Plugin for this Project is enabled, and then click on the CLEAR INDEX button.
Wait for it to re-index, and then try the second examples again, they are autocompleting for me here:
Addressed via: 73216c7
Released as 1.11.0
-> https://github.com/nystudio107/craft-autocomplete/releases/tag/1.11.0
You can update to it via:
composer update nystudio107/craft-autocomplete
It will now generate something that looks like this in storage/runtime/compiled_classes/AutocompleteVariable.php
for Commerce, and other plugins that add Behaviors to the CraftVariable
:
/**
* ...
* @property \craft\commerce\Plugin $commerce
* @method orders($criteria): craft\commerce\elements\db\OrderQuery
* @method subscriptions($criteria): craft\commerce\elements\db\SubscriptionQuery
* @method products($criteria): craft\commerce\elements\db\ProductQuery
* @method variants($criteria): craft\commerce\elements\db\VariantQuery
*/
This means that you will now get autocomplete for:
craft.commerce
craft.orders()
craft.subscriptions()
craft.products()
craft.variants()
...for Commerce specifically. Video of it in action:
Screen.Recording.2022-12-19.at.7.05.17.PM.mov
To ensure it shows up, you can manually regenerate the autocompletes via CLI:
php craft autocomplete/regenerate
If you still don't see it show up, please go to Preferences -> Symfony and ensure Enable Plugin for this Project is enabled, and then click on the CLEAR INDEX button.
I finally got it working, thanks!
But I also noticed it does not work on the EAP version of PhPStorm unfortunately.
On a side note: maybe you could add commerce.discounts
as well?
discounts
already works -- commerce.
isn't a namespace that exists anymore though, at least not with Commerce 3.x
What version of Commerce are you using?
Commerce 4.2.4
Then maybe I was testing the discount when I was still on EAP version.