Skip to content
This repository has been archived by the owner on Feb 23, 2024. It is now read-only.

Filter by Attribute does not display attirbutes for imported XML products #9108

Closed
kmanijak opened this issue Apr 19, 2023 · 11 comments
Closed
Labels
block: filter by attribute Issues related to the Filter by Attribute block. priority: low The issue/PR is low priority—not many people are affected or there’s a workaround, etc. type: bug The issue/PR concerns a confirmed bug.

Comments

@kmanijak
Copy link
Contributor

kmanijak commented Apr 19, 2023

Description

Under certain synthetic circumstances Filter by Attribute shows "There are no products with selected attributes":
image

Filter by Attribute (and some other filters) have been updated recently in this PR, but that wasn't released yet and is scheduled for 10.1.0 (April 24). That means it happens only on trunk since that PR was merged. If you visit this issue later, then this version might've been released already so the issue could be reproduced there.

Steps to reproduce

  1. Setup new env
  2. Use woo-test-environment which imports the products here
  3. Edit Product Catalog
  4. Add Filter by Attribute and Products block
  5. In Filter by Attribute choose some attribute (e.g. Color)
  6. Expected: There are couple of colors options shown in a preview
  7. Actual: There's a notice saying "There are no products with selected attributes"

More details

This happens if products are imported through WP Importer (e.g. via woo-test-environment) and {prefix}_wc_product_attributes_lookup is not correctly propagated. All works fine if products/attributes are added manually or imported manually as CSV.
It may require update in WC Core do ensure the method that populates the table is triggered after the data import.

@kmanijak kmanijak added block: filter by attribute Issues related to the Filter by Attribute block. type: bug The issue/PR concerns a confirmed bug. priority: low The issue/PR is low priority—not many people are affected or there’s a workaround, etc. labels Apr 19, 2023
@kmanijak
Copy link
Contributor Author

There's issue in WC Core re that: woocommerce/woocommerce#25698

@gigitux
Copy link
Contributor

gigitux commented Apr 21, 2023

cc @nielslange This issue affects our E2E test env (playwright). Any thoughts about how to fix it?

We run the command to generate the table too:

wp-env run tests-cli "wp wc tool run regenerate_product_lookup_tables --user=1"

(source code)

@kmanijak
Copy link
Contributor Author

Adding a bit more context:

When I encountered this issue, I made an attempt of switching to CSV in a fork here, as the lookup table population works fine when data is imported through WooCommerce importer (using CSV).

But then I found out WP importer supports only WXR (XML) files as per docs:

Path to one or more valid WXR files for importing. Directories are also accepted.

Also, the regeneration of lookup tables takes a while to complete (ref: p1681913867082209/1681818021.792209-slack-C02FL3X7KR6)

@gigitux
Copy link
Contributor

gigitux commented Apr 21, 2023

Adding a bit more context:

When I encountered this issue, I made an attempt of switching to CSV in a fork here, as the lookup table population works fine when data is imported through WooCommerce importer (using CSV).

But then I found out WP importer supports only WXR (XML) files as per docs:

Path to one or more valid WXR files for importing. Directories are also accepted.

Same here 😅

Also, the regeneration of lookup tables takes a while to complete (ref: p1681913867082209/1681818021.792209-slack-C02FL3X7KR6)

Gotcha!

@nielslange
Copy link
Member

cc @nielslange This issue affects our E2E test env (playwright). Any thoughts about how to fix it?

We run the command to generate the table too:

wp-env run tests-cli "wp wc tool run regenerate_product_lookup_tables --user=1"

(source code)

Thanks for reaching out, @gigitux. I'll look into this issue.

@nielslange
Copy link
Member

@gigitux I looked into this issue, but I'm unable to reproduce it. At woo-test-environment, we're also adding attributes, before regenerating the product lookup table.

@kmanijak Besides the testing steps that you listed above, can you give me additional steps on how to reproduce this issue? For example, on my end, I do not see the Product Template:

Screen Shot 2023-04-21 at 18 31 14

@kmanijak
Copy link
Contributor Author

@kmanijak Besides the testing steps that you listed above, can you give me additional steps on how to reproduce this issue? For example, on my end, I do not see the Product Template:

Apologies @nielslange, I meant Product Catalog not Product Template 🤦 I updated testing steps

@nielslange
Copy link
Member

No problem, @kmanijak. I've just looked closer into this issue, but I'm still unable to see the problem. Here's what I did:

  1. Create a fresh WordPress site.
  2. Set up a test environment using https://github.com/nielslange/woo-test-environment
  3. Ensure that the Twenty Twenty-Three theme is activated.
  4. Open the Product Catalog template.
  5. Remove the current block and add the Filter by Attribute and the Products (beta) blocks.
  6. Look up the Product Catalog template via /shop/classic-shop.

Here's what I see on my end:

Post editor:

Screen Shot 2023-04-21 at 19 01 22
Frontend:

Screen Shot 2023-04-21 at 19 01 53

Could you try running the following command in your terminal:

wp woo-test-environment teardown && wp woo-test-environment setup --blocks

This tears down the current environment and sets it up again. Maybe the good old "have you tried turning it off an on?" also helps in this case. 🤔

@kmanijak
Copy link
Contributor Author

I see why is that and again this is actually a missing information in Steps to Reproduce, which I took for granted.

The whole thing is because the Filter by Attribute (and some other filters) have been updated recently in this PR, but that wasn't released yet and is scheduled for 10.1.0. That means it happens only on trunk since that PR was merged.

If I'm not mistaken, we can use any of the ZIP files from the PRs that were merged later 🤔
E.g. this PR and here's a ZIP file

(TIL a lot about how to write better testing steps and describe issues better. Sorry for the trouble and I'm updating the issue description again 🙇 ).

@nefeline
Copy link
Contributor

nefeline commented Apr 27, 2023

@gigitux regarding:

This issue affects our E2E test env (playwright). Any thoughts about how to fix it?

While I don't have all the details regarding your issue on Playwright, I suspect it might be the same we had with our current infrastructure: the tests were also failing on Puppeteer, as the process for creating and populating the new product meta-lookup table is deferred (triggered via a scheduled action) out-of-the-box: we managed to fix this limitation by enabling direct updates:

Screenshot 2023-04-27 at 10 33 55

See @albarin's PR:

https://github.com/woocommerce/woocommerce-blocks/pull/9029/files

@gigitux
Copy link
Contributor

gigitux commented Apr 27, 2023

@nefeline Thanks for point the PR! I will check it and implement it in Playwright too! 🙇

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
block: filter by attribute Issues related to the Filter by Attribute block. priority: low The issue/PR is low priority—not many people are affected or there’s a workaround, etc. type: bug The issue/PR concerns a confirmed bug.
Projects
None yet
Development

No branches or pull requests

4 participants