-
Notifications
You must be signed in to change notification settings - Fork 144
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
Fix Product Syncing via Feeds #2841
base: main
Are you sure you want to change the base?
Conversation
} | ||
|
||
// Step 2 - Query feeds data from Meta and filter the right one | ||
$feed_id = self::query_and_filter_integration_feed_id(); |
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.
This could throw an error that is currently not being caught
continue; | ||
} | ||
|
||
$woo_feed_name_option_1 = self::FEED_NAME; |
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.
suggest factor out to private function named something like private function pattern_match_feed_names()
private function query_and_filter_integration_feed_id() { | ||
$catalog_id = facebook_for_woocommerce()->get_integration()->get_product_catalog_id(); | ||
if ( '' === $catalog_id ) { | ||
throw new Error( 'No catalog ID' ); |
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.
not being caught in retrieve_or_create_integrationFeed_id()
WC_Facebookcommerce_Utils::log( 'Feed: retrieve_integration_feed_id(): feed_id = '.$feed_id.', created a new feed via Meta API.'); | ||
return $feed_id; | ||
} | ||
|
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.
Maybe we can throw an error or log here. Something like 'couldn't create feed'
}; | ||
add_filter( 'pre_http_request', $response, 10, 3 ); | ||
|
||
$this->api->create_upload( $product_feed_id, $data ); |
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.
Shouldn't there be an assert
here?
private function validate_feed_exists($feed_id) { | ||
$catalog_id = facebook_for_woocommerce()->get_integration()->get_product_catalog_id(); | ||
if ( '' === $catalog_id ) { | ||
throw new Error( 'No catalog ID' ); |
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.
Are the errors stored in the logs or was it a conscious decision to not add any logs here
* | ||
* @internal | ||
*/ | ||
private function query_and_filter_integration_feed_id() { |
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.
This method seems like a lot of logic
Can we have it broken out a bit
@@ -715,4 +715,63 @@ public function test_read_feeds_creates_read_feeds_request() { | |||
$response->data | |||
); | |||
} | |||
|
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.
Can you add a test to check unhappy path
If errors are thrown or logs are generated
Changes proposed in this Pull Request:
The current state of the product syncing via Feeds is broken - while plugin code base has business logic to generate feed file daily and serve the feed file on request, there is no logic for triggering a feed one time upload.
In this PR I am suggesting the following fixes to unblock product sync via feeds:
Trigger a daily feed upload sessions.
Update Feed file content by:
GTIN
to the feed filequantity_to_sell_on_facebook
to the feed fileDetailed test instructions:
A. Run new tests:
./vendor/bin/phpunit --filter ApiTest
./vendor/bin/phpunit --filter fbproductTest
B. Run all tests:
npm run test:php
Changelog entry
Fix - Fixed feeds by requesting a feed file upload session after feed file is generated and added missing new fields to the feed file.