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

Craft Commerce auto-complete broken (again?) #10

Closed
TomDeSmet opened this issue Oct 12, 2022 · 10 comments
Closed

Craft Commerce auto-complete broken (again?) #10

TomDeSmet opened this issue Oct 12, 2022 · 10 comments
Labels
bug Something isn't working

Comments

@TomDeSmet
Copy link

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
@TomDeSmet TomDeSmet added the bug Something isn't working label Oct 12, 2022
@khalwat
Copy link
Contributor

khalwat commented Oct 13, 2022

Seems to be working here?

Screen Shot 2022-10-13 at 6 26 19 PM

Maybe check this file to ensure it has the annotations in it that you'd expect to see?

Screen Shot 2022-10-13 at 6 26 35 PM

@khalwat
Copy link
Contributor

khalwat commented Oct 13, 2022

btw I think it should be:

craft.commerce
craft.commerce.products
craft.commerce.orders

@TomDeSmet
Copy link
Author

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.

@khalwat
Copy link
Contributor

khalwat commented Dec 12, 2022

Are you still having issues with this?

@TomDeSmet
Copy link
Author

Unfortunately yes.

@khalwat
Copy link
Contributor

khalwat commented Dec 19, 2022

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.

Screen Shot 2022-12-19 at 2 37 45 PM

Wait for it to re-index, and then try the second examples again, they are autocompleting for me here:

Screen Shot 2022-12-19 at 2 38 11 PM

khalwat added a commit that referenced this issue Dec 19, 2022
…P Reflection so we can get all methods & properties added via behavior to the CraftVariable. Allows `commerce.orders()` to work, for example ([#10](#10))
@khalwat
Copy link
Contributor

khalwat commented Dec 19, 2022

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.

Screen Shot 2022-12-19 at 2 37 45 PM

@khalwat khalwat closed this as completed Dec 20, 2022
@TomDeSmet
Copy link
Author

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?

@khalwat
Copy link
Contributor

khalwat commented Jan 2, 2023

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?

@TomDeSmet
Copy link
Author

Commerce 4.2.4

Then maybe I was testing the discount when I was still on EAP version.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants