Closed TomDeSmet closed 1 year ago
Seems to be working here?
Maybe check this file to ensure it has the annotations in it that you'd expect to see?
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: https://github.com/nystudio107/craft-autocomplete/commit/73216c7817957fe936e2db4e2f6f6309d7779fa8
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:
https://user-images.githubusercontent.com/7570798/208551498-3219e4a7-ef8b-4bd0-b624-5bad50ff9302.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.
Describe the bug
Similar to this issue: https://github.com/nystudio107/craft-autocomplete/issues/6
craft.commerce
craft.orders
craft.products
None are autocompleted or recognized.
Versions