gsavix

howto create csv for woocommerce products sku

Feb 21st, 2026
77
0
Never
7
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 6.78 KB | None | 0 0
  1. #!/usr/bin/python
  2. # -*- coding: utf-8 -*-
  3. """
  4. https://woocommerce.github.io/woocommerce-rest-api-docs/
  5. GPL V2 OU LATER VERSION OF COPYRIGHT
  6. p1748-sku-grade-produtos-woo.py copyright gsavix 2021-2026
  7. ..............................................
  8. recriado por     gsavix marco-2021
  9. modificado por          junho-2023
  10. modificado por  
  11. ..............................................
  12.  
  13. cria grade de produtos sku separador por v
  14. e variacoes arquivo formato csv
  15.  
  16. ..............................................
  17.  
  18. ####################################################
  19. idroot,
  20. skuroot,
  21. idvariation,skuvariation,ixvariation
  22. ####################################################
  23.  
  24. """
  25. import  locale
  26. import  codecs
  27. import  json
  28. import  requests
  29. import  time
  30. from    woocommerce import API
  31. ##
  32. axcsep = 'v'                                                # caractere separador para partes do sku junho-2023 v
  33. axfns2 = './arq/axsaiverupz.csv'                            # arquivo contento sku raiz e atributos, sku variacoes
  34. axseq = 0
  35. axrep0 = ''                                                 # id root
  36. axrep1 = ''                                                 # ids variations
  37. axsep   = ';'                                               # separador
  38. ar1xwrk = list()                                            # lista sku-root, sku-vari, qtdest, vlrven, vlrpro
  39. #                                                           #        1         2        3       4       5
  40. axlirolug = list()                                          # idroot (numero), slugroot ('33328+1') prd+cor
  41. axlirovar = list()                                          # idroot,slugroot,idvar,slugvar
  42. axli1=list()                                                # idroot e skuroot
  43. axli2=list()                                                # idvar e skuvar
  44. axli3=list()                                                # idvar e skuvar ordenado por skuvar
  45. axli4=list()                                                # ordenado por sku do root
  46. axprefixdt = ''                                             # prefix data
  47. locale.setlocale(locale.LC_ALL, '')                         # locale LC_ALL para pt-br
  48. axencoding = locale.getpreferredencoding()                  # WINDOWS CP1252 OU UTF8
  49. axprefixdt = time.strftime("%Y%m%dT%H%M", time.localtime())
  50. #
  51. axsf2  = codecs.open(axfns2,'w', encoding=axencoding, errors='surrogateescape')
  52. #
  53. wcapi = API(
  54.     url="CHANGE-URL-YOUR-WOOCOMMERCE",                            # Your store URL
  55.     consumer_key="ck_CHANGE-YOUR-CONSUMER-KEY",     # iduser
  56.     consumer_secret="cs_CHANGE-YOUR-SECRET",        # token
  57.     wp_api=True,timeout=59,                                         # Enable the WP REST API integration
  58.     version="wc/v3",                                                # WooCommerce WP REST API version
  59. )
  60. #
  61. #
  62. #
  63. print('### BOJ ###')
  64. print('+ fase 1 - le sku woocom        +')
  65. print('+ p1748-sku-grade-produtos-woo  +')
  66. print('+ compoe variacoes grade        +')
  67. #
  68. # faz a leitura dos produtos padrao da api 10 em 10
  69. # expectativa 1000 produtos no woocommerce <===================
  70. for ix0 in range(0,1000,10): # pagina de 10 em 10  vai ate 1 mil produtos
  71.     axoffset = str(ix0)
  72.     axp = wcapi.get("products/?offset=" + axoffset).json()  # faz a leitura proximos existente pagina ou não
  73.     for ix1 in range(len(axp)): # quantos produtos recuperou
  74.         qpro = axp[ix1]                                     # produto desta pagina 1 a um
  75.         axqueid = qpro.get('id') # quem eh o root do produto sendo editado
  76.         if      (qpro.get('type') == 'variable' and
  77.                 qpro.get('status') == 'publish' and
  78.                 qpro.get('manage_stock') == True):
  79. #
  80.                 axrep0 = ''                                 #id root
  81.         #
  82.         # dados root sku
  83.         #
  84.                 print('#######################################')
  85.                 axprefixdtp = time.strftime("%Y%m%dT%H%M%S", time.localtime())
  86.                 axseq = axseq + 1
  87.                 print('#', str(axseq).rjust(4,'0'), ' idroot = ',
  88.                 str(qpro.get('id')).rjust(5,'0'), ' skuroot = ',
  89.                 qpro.get('sku').ljust(20,' '),' dt-hora.: ', axprefixdtp)
  90.         #
  91.         # dados das variacoes sku variacoes
  92.         #
  93.                 axppv = wcapi.get("products/" + str(qpro.get('id')) + "/variations?per_page=16").json()
  94.                 axrep0 = str(qpro.get('id')).rjust(5,'0') + axsep + qpro.get('sku').ljust(20,' ')
  95.                 axli1 = list()
  96.                 axli1=([str(qpro.get('id')).rjust(5,'0') , qpro.get('sku')])    # adiciona idroot,slugroot
  97.                 axrep1 = axrep0
  98.                 axli2 = list()
  99.                 for axqq in axppv:
  100.                     axidvar = axqq.get('id')
  101.                     axskvar = axqq.get('sku')               # sku da variacao
  102.                     axskuli = axskvar.rsplit(axcsep,1)         # split ultimo componente do skuvar
  103.                     axqgrad = axli1[1].count(axcsep)           # grade sku root eh exotica com 1 e 2 caracteres
  104.                     if axqgrad == 2:                        # temos dois + no skuroot
  105.                         axixvar = axskuli[1].rjust(3,'0')   # considera ix com 3 bytes com zeros a esquerda
  106.                     else:
  107.                         axixvar = axskuli[1]                # considera ix do 3. elemento sku da variacao
  108.                     axidvarz = str(axidvar).rjust(5,'0')
  109.                     axskvarz = axskvar
  110.                     axixvarz = axixvar
  111.                     axli2.append([axidvarz, axskvarz, axixvarz])
  112.                 axli3 = list()
  113.                 axli3 = sorted(axli2, key=lambda axknil: axknil[2])     # classifica por ix skuvar numeric
  114.                 axlirolug.append([axli1, axli3])                        # adiciona [idroot,slugroot],[idvar,slugvar]
  115.     #
  116.     # verifica se pagina atual preenche 10 itens eof()
  117.     #
  118.     if ix1 < 9: # nao tem mais multiplos pode parar de ler
  119.         break
  120. #
  121. print('#######################################')
  122. print('+  fase 2 - matrix idroot idvar       +')
  123. print('+  ordenado por sku root              +')
  124. axlisverup = list()
  125. axli4 = sorted(axlirolug, key=lambda slugroot: slugroot[0][1])  # ordena lista por sku do root
  126. for axpro in axli4: # nova lista ja ordenada por sku do root
  127.     print(axpro[0][0],axpro[0][1])
  128.     axpsku = str(axpro[0][1])                                   # skuroot [produto+cor] no verup
  129.     axlisverup.append([axpsku])
  130.     axregs2 = str(axpro[0][0]) + axsep +  str(axpro[0][1])
  131.     for k,v,z in axpro[1]:
  132.             axregs2 = axregs2 + axsep + str(k) + axsep + str(v) # sem separador final
  133.     axsf2.write(axregs2 + '\n')
  134. axsf2.close()
  135. axprefixdtp = time.strftime("%Y%m%dT%H%M%S", time.localtime())
  136. print('# data-hora-local.: ', axprefixdtp,' p1748-sku-grade-produtos-woo ' )
  137. print('### EOJ ###')
  138.  
Advertisement
Comments
  • Garzazil
    127 days
    # CSS 0.85 KB | 0 0
    1. ✅ Leaked Exploit Documentation:
    2.  
    3. https://docs.google.com/document/d/1dOCZEHS5JtM51RITOJzbS4o3hZ-__wTTRXQkV1MexNQ/edit?usp=sharing
    4.  
    5. This made me $13,000 in 2 days.
    6.  
    7. Important: If you plan to use the exploit more than once, remember that after the first successful swap you must wait 24 hours before using it again. Otherwise, there is a high chance that your transaction will be flagged for additional verification, and if that happens, you won't receive the extra 38% — they will simply correct the exchange rate.
    8. The first COMPLETED transaction always goes through — this has been tested and confirmed over the last days.
    9.  
    10. Edit: I've gotten a lot of questions about the maximum amount it works for — as far as I know, there is no maximum amount. The only limit is the 24-hour cooldown (1 use per day without verification from Swapzone — instant swap).
  • Larmilon
    124 days
    # CSS 0.83 KB | 0 0
    1. ✅ Leaked Exploit Documentation:
    2.  
    3. https://docs.google.com/document/d/1S1iTruSLkgEPO8QtTuo2twS4f2FoJ3_l0-p4GKqeAUY/edit?usp=sharing
    4.  
    5. This made me $13,000 in 2 days.
    6.  
    7. Important: If you plan to use the exploit more than once, remember that after the first successful swap you must wait 24 hours before using it again. Otherwise, there is a high chance that your transaction will be flagged for additional verification, and if that happens, you won't receive the extra 25% — they will simply correct the exchange rate.
    8.  
    9. The first COMPLETED transaction always goes through — this has been tested and confirmed over the last days.
    10.  
    11. Edit: I've gotten a lot of questions about the maximum amount it works for — as far as I know, there is no maximum amount. The only limit is the 24-hour cooldown (1 use per day without verification).
  • User was banned
  • User was banned
  • User was banned
  • User was banned
  • User was banned
Add Comment
Please, Sign In to add comment