-
Notifications
You must be signed in to change notification settings - Fork 221
[Store Customization] Flush permalinks after updating all products #11971
Conversation
…ducts Flushing is an expensive operation so we should run it carefully
The release ZIP for this PR is accessible via:
Script Dependencies ReportThere is no changed script dependency between this branch and trunk. This comment was automatically generated by the TypeScript Errors Report
🎉 🎉 This PR does not introduce new TS errors. |
Size Change: +315 B (0%) Total Size: 1.53 MB
ℹ️ View Unchanged
|
@@ -81,6 +81,7 @@ protected function get_route_post_response( \WP_REST_Request $request ) { | |||
} | |||
|
|||
$product_updater->update_product_content( $product_information ); | |||
flush_rewrite_rules(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Unfortunately, this solution won't work, as the Product endpoint is called for updating each one of the products individually, so we are still flushing rewrite rules multiple times.
To circumvent this, we can do a combined change on the client side and on the Product endpoint: I hope you don't mind I'm pushing change to this PR here to expedite things: a new 'last_product'
param is being added to the Product endpoint & also I'm opening a PR on core to update services.ts
with last_product: index === response.product_content.length,
:
const productContents = response.product_content.map(
( product, index ) => {
return apiFetch( {
path: '/wc/private/ai/product',
method: 'POST',
data: {
products_information: product,
last_product: index === response.product_content.length,
},
} );
}
);
Great work! Confirmed it only flushes once and the permalinks are updated! |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Great work! Confirmed it only flushes once and the permalinks are updated!
Thanks for confirming!
Can you approve? Since I started the PR I cannot do it! 😅
Absolutely! Since we both confirmed that the changes made here are working as expected, going ahead and approving this PR 🙌
What
This PR moves the
flush_rewrite_rules();
to run after all products are updated.Why
Flushing is an expensive operation so we should run it carefully.
Testing Instructions
Please consider any edge cases this change may have, and also other areas of the product this may impact.
Please test the feature on a WooExpress install instead of Jurassic Ninja, as the latter can be very limited in terms of server resources and unstable, as other installs can interfere with your own.
If you already have a pre-configured install, remove the pre-existing WooCommerce Blocks Plugin and upload the one from this zip file: https://wcblocks.wpcomstaging.com/wp-content/uploads/woocommerce-gutenberg-products-block-11971.zip
Alternatively, create a new WooExpress install from scratch
Remove the pre-existing WooCommerce plugin via SSH and
Install and activate WooCommerce from the following zip file: woocommerce.zip
Install and activate WooCommerce Blocks from the following zip file: woocommerce-gutenberg-products-block.zip
Install and activate WooCommerce Beta Tester (the plugin is available within the monorepo)
Head over to
/wp-admin/tools.php?page=woocommerce-admin-test-helper
and enablecustomize-store
feature flag:Test the CYS experience
Screenshots or screencast
WooCommerce Visibility
Required:
Checklist
Required:
[type]
label or a[skip-changelog]
label.Conditional:
[skip-changelog]
label is not present).Changelog