Author Topic: Trying to add product with python using requests library  (Read 816 times)

gigamarr

  • Beginner
  • *
  • Posts: 2
  • A beginner
Trying to add product with python using requests library
« on: October 14, 2019, 19:22:17 pm »
Hello, my goal is to be able to send data from remote python server and add products to virtuemart that way (which of  course is located on another server).

My script does following: (using python requests library)
1. goes to domain.com/administrator/index.php
2. logs in successfully
3. goes to /index.php?option=com_virtuemart&view=product&task=edit&virtuemart_product_id=0 and sends POST data to this url

step 3 goes by without any errors but i don't see new products being added, for now i'm only sending "product_name", and predefined values of hidden inputs with names: task, option, boxchecked, controller, view and one more input which doesn't have a static name, I think it's csrf token, I'm sending that as well. Is what I'm trying to achieve possible with this approach? any guidance is appreciated

pinochico

  • 3rd party VirtueMart Developer
  • Full Member
  • *
  • Posts: 641
    • MiniJoomla
  • Skype Name: support-easysoftware
  • VirtueMart Version: 3
Re: Trying to add product with python using requests library
« Reply #1 on: January 30, 2020, 12:07:29 pm »
- Use python script for creating XML file and this file import to Virtuemart
- Use eMagic for write to DB
www.minijoomla.org  - new portal for Joomla!, Virtuemart and other extensions
XML Easy Feeder - feeds from products, orders and database table
Virtuemart Email Manager - customs email templates

Studio 42

  • Contributing Developer
  • Sr. Member
  • *
  • Posts: 4362
  • Joomla & Virtuemart developper
    • Studio 42 - Virtuemart & Joomla extentions
  • VirtueMart Version: 2.6 & 3
Re: Trying to add product with python using requests library
« Reply #2 on: January 30, 2020, 14:04:49 pm »
You have to write your own script to add the product to DB.
Because you need form token and valid user for VM, it's better to use com_ajax for eg and a plugin or use your own Joomla component to add the product to DB