fix: use webhook variation data as fallback for importation queue#174
Open
luizabrancaglion wants to merge 1 commit into
Open
fix: use webhook variation data as fallback for importation queue#174luizabrancaglion wants to merge 1 commit into
luizabrancaglion wants to merge 1 commit into
Conversation
/produto.obter.php never returns variacoes for parent products, so the queuing condition was always false and new variations added in Tiny were never enqueued for scheduledSync to process. tinyProduct.variacoes (from the webhook dados spread) already carries the full variation list in unwrapped format. Use it as fallback, normalizing to the wrapped format the forEach expects. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Problema
Após
413b1aa, o guard de variação e o POST estão corretos — mas variações novas adicionadas no Tiny nunca chegavam a ser vinculadas ao produto pai no E-Com Plus.Causa raiz: O bloco de enfileiramento (linha 268) verificava
produto.variacoes, que vem do/produto.obter.php. Esse endpoint nunca retorna o arrayvariacoespara produtos pai — a condição era semprefalse, nada era enfileirado, oscheduledSyncnão processava e a variação nunca era vinculada.O payload do webhook já carrega a lista completa de variações em
tinyProduct.variacoes(via spread dedados), no formato não-encapsulado[{codigo, grade, ...}].Correção
Resolve
_variacoesQueuepreferindo o resultado do/produto.obter.php(encapsulado, quando presente) e usandotinyProduct.variacoesnormalizado como fallback. OforEache toda a lógica downstream permanecem iguais.Fluxo completo após este PR
__importation.skuscom;:parentId← este fixscheduledSyncprocessa cada SKU → guard de413b1aadetectaproduct.sku !== produto.codigo→ POST/products/:id/variations.json→ variação vinculada ✓Como testar
scheduledSync)#<storeId> POST /products/.../variations.json <sku-variacao>🤖 Generated with Claude Code