Skip to content

craft_ prefix compatibility and limiting to availableForPurchase#1

Closed
jmauzyk wants to merge 2 commits intoethercreative:v1from
jmauzyk:v1
Closed

craft_ prefix compatibility and limiting to availableForPurchase#1
jmauzyk wants to merge 2 commits intoethercreative:v1from
jmauzyk:v1

Conversation

@jmauzyk
Copy link
Copy Markdown

@jmauzyk jmauzyk commented Oct 2, 2019

Changes proposed in this pull request:

  • Add table alias for innerJoin used in ProductQueryExtended

In its current form, ProductQueryExtended produces the following error on Craft 3 installs using databases migrated from Craft 2 with the craft_ table prefix:

SQLSTATE[42S22]: Column not found: 1054 Unknown column 'purchase_counts.order_count' in 'field list'

Adding a table alias to the innerJoin resolves this issue.

@jmauzyk jmauzyk closed this Oct 2, 2019
@jmauzyk jmauzyk reopened this Oct 2, 2019
@jmauzyk jmauzyk changed the title Added table alias for craft_ prefix compatibility craft_ prefix compatibility and limiting to availableForPurchase Oct 2, 2019
@jmauzyk
Copy link
Copy Markdown
Author

jmauzyk commented Oct 2, 2019

Also wanted to find a way to limit results to only products that are available for purchase. This is important for us because although we do not sell products after they are continued, we keep the pages enabled for documentation purposes. Filtering out products that are not purchasable would allow us to provide users with only products that are relevant and available.

@existenceltd
Copy link
Copy Markdown

I'd really appreciate this being merged in as we'd love to use this on our site but can't while it's coming up with this error: SQLSTATE[42S22]: Column not found: 1054 Unknown column 'purchase_counts.order_count' in 'field list'

@Tam
Copy link
Copy Markdown
Member

Tam commented Oct 24, 2019

Closing this as I've manually merged the fix into the next release.

I haven't merged the limit to available part since you can already do this. Both craft.purchasePatterns.related and extended return a regular Commerce Product Query so you can use the existing availableForPurchase param.

{% set products  = craft.purchasePatterns.related(myProduct).availableForPurchase().all() %}

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

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants