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

Commit

Permalink
use set_slug rather than wp_update_post for updating the product perm…
Browse files Browse the repository at this point in the history
…alink.
  • Loading branch information
nefeline committed Dec 1, 2023
1 parent 63355ea commit 25067f3
Showing 1 changed file with 1 addition and 8 deletions.
9 changes: 1 addition & 8 deletions src/Patterns/ProductUpdater.php
Original file line number Diff line number Diff line change
Expand Up @@ -257,6 +257,7 @@ public function update_product_content( $ai_generated_product_content ) {
$product->set_name( $ai_generated_product_content['title'] );
$product->set_description( $ai_generated_product_content['description'] );
$product->set_regular_price( $ai_generated_product_content['price'] );
$product->set_slug( sanitize_title( $ai_generated_product_content['title'] ) );
$product->save();

$update_product_image = $this->update_product_image( $product, $ai_generated_product_content );
Expand All @@ -266,14 +267,6 @@ public function update_product_content( $ai_generated_product_content ) {
}

$this->create_hash_for_ai_modified_product( $product );

// Update the post permalink to match the new AI-generated product title.
wp_update_post(
array(
'ID' => $product->get_id(),
'post_name' => sanitize_title( $ai_generated_product_content['title'] ),
)
);
}

/**
Expand Down

0 comments on commit 25067f3

Please sign in to comment.