Guest User

Untitled

a guest
Aug 19th, 2018
101
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.09 KB | None | 0 0
  1. #!/bin/bash
  2. echo -e "Importing products now!"
  3.  
  4. OLDIFS=$IFS
  5. while IFS='|' read -r sku images product_title short_description cats weight regular_price stock_qty manage_stock length height width
  6. do
  7. DIMS=({\"length\":\"${length}\"\,\"width\":\"${width}\"\,\"height\":\"${height}\"})
  8. echo ${DIMS[@]}
  9.  
  10.  
  11. IFS=", "
  12. read -a CATEGORIES <<<$cats
  13. #reset IFS
  14. IFS=$OLDIFS
  15. CATS=([{\"id\":${CATEGORIES[0]}},{\"id\":${CATEGORIES[1]}}])
  16. echo ${CATS[@]}
  17.  
  18. echo SKU = ${sku}
  19. echo Image = ${images}
  20. echo Title = ${product_title}
  21. echo Desc = ${short_description}
  22. echo Weight = ${weight}
  23. echo Price = ${regular_price}
  24. echo Stock Qty = ${stock_qty}
  25. echo Manage Stock = ${manage_stock}
  26.  
  27.  
  28. wp media import "${images}" --featured_image --post_id=$(wp wc product create --sku="${sku}" --name="${product_title}" --short_description="${short_description}" --weight="${weight}" --regular_price="${regular_price}" --stock_quantity="${stock_qty}" --manage_stock="${manage_stock}" --dimensions=${DIMS[@]} --categories=${CATS[@]} --allow-root --user=siteadmin | awk '{print $4}') --user=siteadmin --allow-root
  29. IFS=$OLDIFS
  30. done < product-new-final.txt
Add Comment
Please, Sign In to add comment