Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Create/Update products sync to facebook with Batch API #2672

Merged
merged 3 commits into from
Jan 2, 2024

Conversation

rahulraina7
Copy link
Collaborator

@rahulraina7 rahulraina7 commented Dec 14, 2023

Changes proposed in this Pull Request:

[1/2]
Currently the video syncing is only supported by batch-api / feed upload

This pull requests adds the following

  • Replace update product item calls with batch api call
  • Replace create product item calls with batch api call

flows are affected

  • Move updating/saving a single product to batch api (This IMO is the major change here, as it changes an existing functionality completely)

Tests

Changelog entry

Add - Create/Update products sync to facebook with Batch API

@rahulraina7 rahulraina7 changed the title Add support for syncing(creating/updating) single products using Cata… Create/Update products sync to facebook with Batch API Dec 14, 2023
@budzanowski budzanowski requested a review from a team December 14, 2023 07:26
@ibndawood
Copy link
Contributor

Thank you, @rahulraina7 for the PR. I'll do a review now.

Copy link
Contributor

@ibndawood ibndawood left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thank you, @rahulraina7, for your patience. The changes look good to me. I've tested the simple product, variable product creation and update. They work as expected. I also looked into the logs and saw items_batch being called instead of the Graph ID.

However, there is only one blocker related to the code: the usage of update_product_item within the update_fb_visibility method. Please verify if we should also switch this to the batch API call.

I've added some minor questions and suggestions. They are not blockers.

I've approved the PR in advance as it works as described. I'll trust you to resolve the blocker and merge the PR.

@@ -1175,7 +1178,7 @@ public function on_simple_product_publish( $wp_id, $woo_product = null, &$parent

if ( $fb_product_item_id ) {
$woo_product->fb_visibility = Products::is_product_visible( $woo_product->woo_product );
$this->update_product_item( $woo_product, $fb_product_item_id );
$this->update_product_item_batch_api( $woo_product, $fb_product_item_id );
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Are we replacing all calls to update_product_item with update_product_item_batch_api? In that case, we still have update_product_item call being made here: https://github.com/woocommerce/facebook-for-woocommerce/blob/b8c26af50a7655f30ce9cb8e45a2f4ec92fb9681/facebook-commerce.php#L2996

Can you please verify if this needs to be replaced?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@ibndawood - thank you for pointing this out. I am of the opinion that lets leave this function as it is, as this is merely changing the visibility of the product. Even though we could possible migrate to the new API, but that prepares an entire product again with a new Woo Product class and makes the code a bit more verbose IMO, because the current way of preparing a product for sending batch updates sends the entire product, instead of just say the visibility in this case.

Let me know what you think ?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I understand. We can proceed without changing this function.

facebook-commerce.php Show resolved Hide resolved
facebook-commerce.php Show resolved Hide resolved
facebook-commerce.php Outdated Show resolved Hide resolved
includes/Products/Sync/Background.php Show resolved Hide resolved
facebook-commerce.php Show resolved Hide resolved
facebook-commerce.php Show resolved Hide resolved
includes/fbutils.php Outdated Show resolved Hide resolved
includes/fbutils.php Outdated Show resolved Hide resolved
@budzanowski
Copy link
Contributor

@rahulraina7 is this all or are you working on some things still?

@ibndawood how does this look after the last updates?

@ibndawood
Copy link
Contributor

@budzanowski - Looks good to me. I've already approved.

@rahulraina7
Copy link
Collaborator Author

@rahulraina7 is this all or are you working on some things still?

@ibndawood how does this look after the last updates?

Hello @budzanowski - yes all is good, I am just waiting for the holiday period to be over. To have no surprise issues, I will merge this in first week of January. I am not sure of the release cycles of the package how frequent it is done.

@budzanowski
Copy link
Contributor

@rahulraina7

We release every week ( Tuesday/Wednesday ) if there is something to release. Please ping after the merge.
Thanks!

@rahulraina7 rahulraina7 merged commit 18d93b5 into develop Jan 2, 2024
6 checks passed
@rahulraina7 rahulraina7 deleted the product_batch_api_sync branch January 2, 2024 04:49
@ibndawood ibndawood added the changelog: add A new feature, function, or functionality was added. label Jan 3, 2024
@ibndawood ibndawood added changelog: none Skip changelog entry for this PR and removed changelog: add A new feature, function, or functionality was added. labels Jan 3, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
changelog: none Skip changelog entry for this PR
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants