[Store Customization] Flush permalinks after updating all products (https://github.com/woocommerce/woocommerce-blocks/pull/11971)
* Flush after updating all products, not after updating each of the products Flushing is an expensive operation so we should run it carefully * Remove the index param and add the last_product param to the Product endpoint. --------- Co-authored-by: Patricia Hillebrandt <patriciahillebrandt@gmail.com>
This commit is contained in:
parent
8f99863a2e
commit
ce71e30732
|
@ -260,7 +260,6 @@ class ProductUpdater {
|
|||
),
|
||||
)
|
||||
);
|
||||
flush_rewrite_rules();
|
||||
|
||||
require_once ABSPATH . 'wp-admin/includes/media.php';
|
||||
require_once ABSPATH . 'wp-admin/includes/file.php';
|
||||
|
|
|
@ -46,14 +46,14 @@ class Product extends AbstractRoute {
|
|||
'callback' => [ $this, 'get_response' ],
|
||||
'permission_callback' => [ Middleware::class, 'is_authorized' ],
|
||||
'args' => [
|
||||
'index' => [
|
||||
'description' => __( 'The business description for a given store.', 'woo-gutenberg-products-block' ),
|
||||
'type' => 'integer',
|
||||
],
|
||||
'products_information' => [
|
||||
'description' => __( 'Data generated by AI for updating dummy products.', 'woo-gutenberg-products-block' ),
|
||||
'type' => 'object',
|
||||
],
|
||||
'last_product' => [
|
||||
'description' => __( 'Whether the product being updated is the last one in the loop', 'woo-gutenberg-products-block' ),
|
||||
'type' => 'boolean',
|
||||
],
|
||||
],
|
||||
],
|
||||
'schema' => [ $this->schema, 'get_public_item_schema' ],
|
||||
|
@ -82,6 +82,12 @@ class Product extends AbstractRoute {
|
|||
|
||||
$product_updater->update_product_content( $product_information );
|
||||
|
||||
$last_product_to_update = $request['last_product'] ?? false;
|
||||
|
||||
if ( $last_product_to_update ) {
|
||||
flush_rewrite_rules();
|
||||
}
|
||||
|
||||
return rest_ensure_response(
|
||||
array(
|
||||
'ai_content_generated' => true,
|
||||
|
|
Loading…
Reference in New Issue