Advertisement
Guest User

Dominykas

a guest
Sep 21st, 2017
511
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. See how it's done in products.json file:
  2.  
  3. We have the parent Variable product with  "attribute_name": "Gendre" . If your variable product belongs to more than one attribute, then add it. For example: "attribute_name2": "Size".
  4.  
  5. --------------------------------------------
  6.  {
  7.    "product_id": 200,
  8.    "type": "variable",
  9.    "name": "My product 2",
  10.    "description": "My product description 2",
  11.    "regular_price": 0,
  12.    "manage_stock": 0,
  13.    "stock": 0,
  14.    "weight": 0,
  15.    "attribute_name": "Gendre",
  16.    "attribute_name2": "Size",
  17.    "has_variations": 1
  18.  }
  19. --------------------------------------------
  20.  
  21. Secondly, what we have here is a child product variation:
  22. Here we assign a product variation to a certain attribute and its value. "attribute_name": "Gendre" and "attribute_value": "Woman". Here, I will also add our second attribute "attribute_name2": "Size" and value  "attribute_value2": "Small",
  23.  
  24. {
  25.    "type": "product_variation",
  26.    "parent_product_id": 200,
  27.    "description": "My product variation 1",
  28.    "regular_price": 120,
  29.    "manage_stock": 1,
  30.    "stock": 5,
  31.    "weight": 0,
  32.    "attribute_name": "Gendre",
  33.    "attribute_value": "Woman",
  34.    "attribute_name2": "Size",
  35.    "attribute_value2": "Small"
  36. }    
  37.  
  38. What you to do next is to go over the import script and process attribute_name2 and attribute_value2 too.
  39.  
  40. function get_attributes_from_json( $json ) - should include attribute_name2 and attribute_value2 too.
  41.  
  42. The same is function get_products_and_variations_from_json( $json, $added_attributes )  - your attribute_name2 and attribute_value2 should be there...
Advertisement
RAW Paste Data Copied
Advertisement