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

Store Customization > Update products with AI generated content #11155

Merged
merged 36 commits into from
Oct 24, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
36 commits
Select commit Hold shift + click to select a range
178a022
Introduce the ProductUpdater class.
nefeline Oct 5, 2023
6df499c
Update the image assignment for the default products content.
nefeline Oct 5, 2023
a754030
Update the default products content.
nefeline Oct 5, 2023
d94eab8
Introduce the generate_content and get_placeholder_products methods.
nefeline Oct 5, 2023
884ad30
Merge branch 'trunk' into add/ai-generated-content-for-products
nefeline Oct 10, 2023
8adfc7f
Update the get_placeholder_products method and introduce the new crea…
nefeline Oct 10, 2023
aa753fb
Verify the hash of the product content and compare it with the hash o…
nefeline Oct 10, 2023
d0688db
Add docblocks and update the structure for the ProductUpdater class.
nefeline Oct 10, 2023
31d5942
Pass the vertical images as a param for the PatternUpdater and the Pr…
nefeline Oct 11, 2023
c6dae0b
Update the provided variable to the PatternUpdater class.
nefeline Oct 11, 2023
057fe93
Update the ProductUpdater class to include the requirements for usage…
nefeline Oct 11, 2023
35b0719
remove unnecessary calls to post/product images.
nefeline Oct 11, 2023
9659d40
Update the loop for generating products.
nefeline Oct 11, 2023
11f6eb7
Further adjustments to the Product Updater.
nefeline Oct 11, 2023
18e7b84
Provide the business_description as a param for the generate_content …
nefeline Oct 11, 2023
f18ebf5
Merge branch 'trunk' into add/ai-generated-content-for-products
nefeline Oct 11, 2023
8838406
Update the default timeout for the AI connection; update the path to …
nefeline Oct 11, 2023
656fb99
Add new neutral placeholder images for products and patterns.
nefeline Oct 13, 2023
7bed64e
Update the prompt and the logic for the placeholder images.
nefeline Oct 13, 2023
cd4fb68
Merge trunk and resolve conflicts.
nefeline Oct 17, 2023
e696300
Remove placeholder images.
nefeline Oct 17, 2023
38f3b42
Merge branch 'trunk' into add/ai-generated-content-for-products
nefeline Oct 18, 2023
fcd471d
Increase max execution time
nefeline Oct 19, 2023
09df952
Merge branch 'trunk' into add/ai-generated-content-for-products
nefeline Oct 19, 2023
806bcf8
Update the products query.
nefeline Oct 20, 2023
88ea1d8
Move the media_sideload_image function dependencies to outside of the…
nefeline Oct 20, 2023
c334df4
Update text content.
nefeline Oct 20, 2023
29b3ba1
Merge branch 'trunk' into add/ai-generated-content-for-products
nefeline Oct 20, 2023
6a392d1
Merge branch 'trunk' into add/ai-generated-content-for-products
nefeline Oct 22, 2023
3da76eb
Address code review.
nefeline Oct 24, 2023
6333f15
bail early if no business description provided.
nefeline Oct 24, 2023
5ddb593
Add an extra safety check in case of query errors.
nefeline Oct 24, 2023
f97f73d
Address CR.
nefeline Oct 24, 2023
4fcc41e
Merge branch 'trunk' into add/ai-generated-content-for-products
nefeline Oct 24, 2023
862e0ec
Merge branch 'trunk' into add/ai-generated-content-for-products
nefeline Oct 24, 2023
da8cee2
Merge branch 'trunk' into add/ai-generated-content-for-products
nefeline Oct 24, 2023
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 4 additions & 1 deletion src/BlockPatterns.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@

use Automattic\WooCommerce\Blocks\Domain\Package;
use Automattic\WooCommerce\Blocks\Patterns\PatternUpdater;
use Automattic\WooCommerce\Blocks\Patterns\ProductUpdater;
use Automattic\WooCommerce\Blocks\Verticals\Client;
use Automattic\WooCommerce\Blocks\Verticals\VerticalsSelector;

Expand Down Expand Up @@ -249,8 +250,10 @@ public function update_patterns_content( $value ) {
return $vertical_id;
}

$vertical_images = ( new Client() )->get_vertical_images( $vertical_id );
$business_description = get_option( VerticalsSelector::STORE_DESCRIPTION_OPTION_KEY );

return ( new PatternUpdater() )->create_patterns_content( $vertical_id, new Client(), $business_description );
( new PatternUpdater() )->generate_content( $vertical_images, $business_description );
( new ProductUpdater() )->generate_content( $vertical_images, $business_description );
}
}
13 changes: 3 additions & 10 deletions src/Patterns/PatternUpdater.php
Original file line number Diff line number Diff line change
Expand Up @@ -33,19 +33,12 @@ public function __construct() {
/**
* Creates the patterns content for the given vertical.
*
* @param int $vertical_id The vertical id.
* @param Client $verticals_api_client The verticals API client.
* @param string $business_description The business description.
* @param array|WP_Error $vertical_images The array of vertical images.
* @param string $business_description The business description.
*
* @return bool|WP_Error
*/
public function create_patterns_content( $vertical_id, $verticals_api_client, $business_description = '' ) {
if ( ! is_int( $vertical_id ) ) {
return new WP_Error( 'invalid_vertical_id', __( 'The vertical id is invalid.', 'woo-gutenberg-products-block' ) );
}

$vertical_images = $verticals_api_client->get_vertical_images( $vertical_id );

public function generate_content( $vertical_images, $business_description ) {
if ( is_wp_error( $vertical_images ) ) {
return $vertical_images;
}
Expand Down
Loading
Loading