bigcommerce / bigcommerce-for-wordpress

A headless commerce integration for WordPress, powered by BigCommerce
https://www.bigcommerce.com/wordpress/
GNU General Public License v2.0
108 stars 46 forks source link

On Demand Sync of New/Updated Items Not Working #312

Closed frg-tech closed 2 years ago

frg-tech commented 2 years ago

Expected behavior

New/Updated Items reflected in Wordpress after sync

Actual behavior

"0 Products Successfully Synced"

Steps to reproduce behavior

  1. Add a product to the Wordpress channel on BigCommerce
  2. On Products page of Wordpress plugin, select New/Updated since last sync from dropdown menu and select Sync Products button.

Workaround or possible solution

If we do an All Products sync instead of just new/updated, the newly added products will synchronize to Wordpress just fine, but this breaks other functionality with our site.

frg-tech commented 2 years ago

Not long after making this post yesterday I noticed that the plugin had been updated. I checked the notes and was thrilled to see that the issue I'm having was addressed.

Fixed the 'New/Updated since last sync' import. The import will pull new products as well as update existing ones. Previously the 'New/Updated since last sync' updated existing products only

So I came in this morning and added a new product to my Wordpress channel on our BigCommerce site. Unfortunately when I tried to use 'New/Updated since last sync', is still will not pick up the new item.

I enabled logging in the diagnostic tab, so hopefully this will help. BC4WP_debug.log

BC4WP_sync_new_items

frg-tech commented 2 years ago

I waited and tried again just in case it was an issue of needing time, but it never worked. I went ahead and did a full sync and everything worked as expected.

Here is my sync attempts, and the log from the successful full sync. BC4WP_debug-2.log

BC4WP_sync_new_items-2

yuenvision commented 2 years ago

There's a setting in your BC4WP admin to enable webhooks under Product Sync.

Please make sure that is turned on. Your screenshot indicates they are off.

On Sat, Oct 30, 2021 at 6:15 AM Frg Tech @.***> wrote:

I waited and tried again just in case it was an issue of needing time, but it never worked. I went ahead and did a full sync and everything worked as expected.

Here is my sync attempts, and the log from the successful full sync. BC4WP_debug-2.log https://github.com/bigcommerce/bigcommerce-for-wordpress/files/7446608/BC4WP_debug-2.log

[image: BC4WP_sync_new_items-2] https://user-images.githubusercontent.com/84391379/139534175-8bdd6177-3155-42f8-9990-60c9deb06ce4.jpg

— You are receiving this because you are subscribed to this thread. Reply to this email directly, view it on GitHub https://github.com/bigcommerce/bigcommerce-for-wordpress/issues/312#issuecomment-955207689, or unsubscribe https://github.com/notifications/unsubscribe-auth/AAHFUJ4WFNNPARMBOTNXFELUJPVYLANCNFSM5G7RWUPQ . Triage notifications on the go with GitHub Mobile for iOS https://apps.apple.com/app/apple-store/id1477376905?ct=notification-email&mt=8&pt=524675 or Android https://play.google.com/store/apps/details?id=com.github.android&referrer=utm_campaign%3Dnotification-email%26utm_medium%3Demail%26utm_source%3Dgithub.

-- Paul Yuen Modern Tribe https://tri.be/ | Sr. Product Owner @.***

frg-tech commented 2 years ago

That did the trick!

I didn't realize that the webhooks needed enabled for that since the full sync worked without it.

Might be nice to have a check in place when initiating a 'New/Updated since last sync' sync that pops up a notification or similar to inform the user it's a requirement.

Thanks for the help!

frg-tech commented 2 years ago

I'm sorry to say it only worked that one time.

I tried the last 2 days and it just won't work until I do full sync. BC4WP_sync_new_items-3

https://gist.github.com/frg-tech/034e96ab1a608987095b3121eb9323ab

tyla-taylor commented 2 years ago

HI @frg-tech , webhooks do not need to be enabled for this fix to work. We specifically tested for that. Can you also provide a screenshot of your Product Sync in the BC Settings area in WP? Thank you for providing your debug logs, we will take a look and try to figure out what's going on.

frg-tech commented 2 years ago

Hi @tyla-taylor, Sorry I've been out of the office.

There is a screenshot above of my Product Sync settings. The only thing different is I turned on webhooks under the advice of @yuenvision.

So are you saying it should not matter whether webhooks are enabled or not? Or would you like me to disable them?

tyla-taylor commented 2 years ago

Hi @frg-tech. As a temporary solution we suggest you:

  1. Go to plugin settings
  2. Make as suggested on screenshot http://p.tri.be/CDxDPK

This prevents a full sync and also makes new products import work. We will be working on a permanent solution to this.

frg-tech commented 2 years ago

SIGH

I knew better than to try this, but now my entire store is syncing and I have no way to stop it. I specifically only wanted the items I marked to be sync'd because of the storage availability on our Wordpress site.

There really needs to be a cancel sync button somewhere. I've put the setting for Automatic Listing back to NO, but that isn't stopping it.

This is a nightmare.

BC4WP_sync_new_items-4

frg-tech commented 2 years ago

Ok I'm completely lost now.

I went and deleted all the products from BC4WP except products I had previously listed on the site. Fearing that deleting everything would remove the images from the archived posts. So I had 21 products remaining when I finished.

I then went to the BigCommerce page and removed everything from the WP channel except those same 21 products. BC4WP_sync_new_items-6

Thinking everything was back the way it should be, I added a single product to the WP channel on the BC site, then I initiated a sync from BC4WP and chose new/updated just to check. It didn't update anything of course. So I did the full product sync like I was doing before, but since I had Automatic Listing set to NO, I thought it would work like it did before and just sync the items marked on BC as 2 channel. (22 Products)

When it got top the last stage of sync, I come to find out it is syncing everything visible now! BC4WP_sync_new_items-5

I just updated the plugin again before syncing. Was that a mistake?

Is there any possible way for me to just have the products I want on my WP site, and add new products ala-carte without it wanting to sync everything? Do I need to downgrade the plugin?

Please help.

Edit: I just checked and it didn't mark the products on BC as 2Channel, so it's importing all visible products on my BC store even though they are not marked for the WP channel.

yuenvision commented 2 years ago

Ok. I want to be sure I understand your situation correctly:

I can understand that products newly added to your channel's listings might not sync on the partial sync option to import "new/updated since last sync" since that process is looking for a modified date on the product object and comparing it to your last sync's date. Adding a product to your listing may not change its modified date from the Catalog API since you haven't changed any data on the product object.

Is everything else above correct?

frg-tech commented 2 years ago

Hi @yuenvision

You are on a single-channel setup

no 2 Channel (as I understand it, 1 channel is my BC store, and the second channel is WP)

You have a catalog of 160 products

Visible yes, total is over 300

Your WP instance is connected to the channel called2Channel

I believe it's called Fishingreport.Friscorodandgun.Com BC-Channels

You have 22 products attached to 2Channel and that subset of products are the desired products to appear in WP

Yes

You have verified that 2Channel ONLY has 22 products in it by filtering to the listings in that channel from the Product list view in BC admin

Yes, see screenshot above

You have disabled the sync via cron in BC4WP

Not sure. Where is that setting? The screenshot I posted above are the sync settings I know of.

You have turned off webhooks

Same, see above screenshot

You have turned off the automatic listing option in BC4WP and are set to manually curate your channel's listings

Same. yes

When you attempt to sync your products to WP, all 160 products are imported

Yes

I am at home now, and I see it has finally finished syncing. It appears it has added the newly synced items as "Drafts". BC-Channels-2

So my needs are this. I only want to add one or a few products to my WP site at a time. The WP site is only our blog and a place to add a "Product of the Day".

ie... https://fishingreport.friscorodandgun.com/2021/11/04/hatteras-island-fishing-report-2079/

It was working partially before by doing a full sync and it would query the BC site to see what was marked for the WP site and only import those items. This always took a long time to sync all 13 steps which is why I started this thread to try and get the new/updated sync to work. (which was only 6 steps)

I hope that explains everything, but please let me know if anything is unclear.

Here is the log from today. BC4WP-Sync.log

yuenvision commented 2 years ago

Thinking everything was back the way it should be, I added a single product to the WP channel on the BC site, then I initiated a sync from BC4WP and chose new/updated just to check. It didn't update anything of course.

After a little more investigation, my theory above was correct: when adding an older product from the catalog to the Channel Listings, it does not update the modified date on the product at the Catalog level. This means that when BC4WP attempts to filter the import to products with modified dates newer than the last sync, it will not pull in the products that were newly added to the Channel Listings. It will pull in newly created or newly modified products that are in the Channel Listing, but not older products that were recently added to the Channel. We'll look into a way to filter for that use case.

None of this explains why your entire catalog is being imported, rather than just the products attached to your Channel. That seems to be a separate issue, probably related to turning on "Automatically list new BigCommerce Products to this Channel" and then turning it back off. We are aware that there have been some recent odd behaviors in the BC admin with regards to Products accuracy in Channel Listings. BC has also been notified.

Something else you mentioned was an ability to gracefully abort a sync. A few others have requested such a feature. I'll write a feature ticket for this.

Sidenote: For clarity, when I asked if you were on a single or multi-channel setup, that was from the perspective of the plugin. BC4WP has a filter that you have to turn on in the code in order to enable multi-channel (the ability to connect multiple channels to a single WP instance for the purposes of things like multi-regional, multi-currency, multi-lingual, etc). I was checking to see if you'd enabled that. It sounds like from the plugin's perspective, you are a single-channel merchant because you only have a single channel connected to WP.

frg-tech commented 2 years ago

Hi @yuenvision, Since I hadn't heard back from you, I ended up having to perform another sync regardless of the possibility of syncing the entire catalog again because I needed to add more products. This time it did not sync the entire visible or complete catalog. I did not change a single setting since the time it sync'd the visible catalog that I took the screenshot from above. Maybe has to do with your assumption you just stated?

probably related to turning on "Automatically list new BigCommerce Products to this Channel" and then turning it back off

Anyway, I'm glad I didn't have to deal with deleting all those extra products again. I will be adding more products later today and will post if I have more issues. For completeness I'm adding a screenshot of my sync attempts. I meant to add it to the last post but forgot to. This also show that my last sync worked correctly. (ie.. full sync only added the products I marked in BC for 2Channels)

BC4WP_sync_new_items-7

I want to say I do appreciate the active work being done on this plugin. I didn't mean to sound ungrateful, but it can get a bit overwhelming when bugs create a lot of unexpected work, and the uncertainty that goes along with it. I hope my feedback with help in squashing these bugs.

Thanks!

tyla-taylor commented 2 years ago

Based on the above comment, syncing issues seem to have been resolved. We have also since added the ability to gracefully abort a sync in v4.22.0. If any new issues arise, please open a new ticket. Thanks.