Skip to content

Conversation

@codegen-sh
Copy link
Contributor

@codegen-sh codegen-sh bot commented May 19, 2025

Issue

When a product is disabled in Magento 2, the real-time updates feature is not properly removing the product from Clerk until a full sync is performed. Additionally, the "Last change to a product" timestamp is only updated after the full sync.

Root Cause

After investigating the code, I identified several potential issues:

  1. The removeProduct method in the Api class was using json_encode for the products parameter, which might not be the expected format for the Clerk API.
  2. There was insufficient error handling and logging in the API calls, making it difficult to diagnose issues.
  3. The CURL requests lacked proper error handling and HTTP status code checking.

Changes Made

  1. Modified the removeProduct method to use a simple array instead of a JSON-encoded string for the products parameter.
  2. Added comprehensive logging throughout the API call process to help diagnose issues:
    • Detailed logging before and after product removal attempts
    • Logging of full request details including URLs and parameters
    • Logging of API responses
  3. Enhanced CURL error handling:
    • Added CURLOPT_FAILONERROR and other options for better error detection
    • Added HTTP status code checking
    • Improved error logging with more context

Testing

These changes will provide detailed logs when a product is disabled, making it possible to diagnose any issues with the real-time updates. The logs will show:

  • When a product is detected as disabled
  • The exact parameters being sent to the Clerk API
  • Any errors that occur during the API call
  • The response from the Clerk API

This should help identify and resolve the issue with real-time updates not reflecting product changes until a full sync is performed.


💻 View my workAbout Codegen

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant