How do I get / set product price programmatically? - php

I'm using Woocommerce and trying to make a desktop application which manipulates products and prices (planning to use visual basic).
I've searched the internet a lot however couldn't find a good answer to where the product names and their prices are stored.
Can I manipulate data using php or mysql from desktop?

WooCommerce stores products in the 'posts' table of the schema. Instead of manually updating the DB, I would use the provided API.
From there, you can let WooCommerce handle all of the nitty gritty of updating products, managing the data structure, etc.
This also allows you to not have updates to WooCommerce break your application if they change their DB layout.
WooCommerce API v3

Related

Prestashop sharing product stock between two seperate prestashop websites

I have a two seperate websites(f.e. abc.com and 123.com) Shops have the same products, but different prices. I want that these two stores would share product stock and nothing more. So I guess it's just one column from database. Is there a good way to synchronize product stock between two seperate prestashop websites?
In order to achieve your goal. You should use the multistore functionality in Prestashop (sharing products and stock), see doc.prestashop.com/display/PS16/Managing+Multiple+Shops
As I assume you aren't using it for a specific reason, you would need to go and create your own module. Your module should register to the actionUpdateQuantity hook, meaning everytime your stock changes, it should do something, namely send a message to the other shop.
Normally, you would use the Prestashop webservice for this kind of behaviour, but as the webservice has some problems with stock management (see http://forge.prestashop.com/browse/PSCSX-3170, mainly having to do with the advanced stock management). I don't know if you use the ASM functionality, but I've created an example module for syncing your stocks. It can be adapted to be compatible with ASM functionality.
In the module configuration, you'll find the Sync URL of the current shop, you can use that URL in the other shop. So you'll install the module on both shops and cross reference them. I've created a separate sync.php file which will be called to sync the stock. As said, normally you should use the webservice functionality for this (and if you dont use ASM, you can adapt it to use the webservice, if you do use ASM, you must adapt it to allow for stock movements and valuation).
For the code, see the repository at https://github.com/mwienk/prestashop-syncstock

insert query for adding product in prestashop

I have an existing desktop application for managing my shop. Now Im making an online store, for that I have used prestashop. I have to add all the products from my old application to online shop. Also in future I will add new products through desktop application only. But when I add new product it should be reflect in the online shop.
Im planning to update the database from desktop application. For that I need to view the insert query for adding a product in prestashop. But I didnt find anything.Please guide me.
Thanks in advance,
iijb
For a simple product creation, you will have to populate these tables :
ps_product
ps_product_shop (if prestashop version >= 1.5)
If you have combinations (E.g. Blue XL Tshirt, Black S Tshirt, ...) you need to populate these tables too (but this won't be easy) :
ps_product_attribute
ps_product_attribute_combination
ps_product_attribute_shop
You have to look the database schema with phpmyadmin to see field names.
Anyway I suggest you to study how works modules such as oscommerce to prestashop, or magento to prestashop.
Good luck
I run Prestashop 1.6, I believe that you will also have to enter the description in ps_product_lang. You may also have to make an entry of physical quantity available in ps_stock_available. For sure if you use advanced stock management.
Hope it helps!

Accept product feed into magento via api (XML)

Is it possible to receive a product feed via external api? I've looked at the magento api and I can see how to produce an XML web service to feed products out, but I need to feed information into magento.
I have a supplier of products with an XML api (SOAP). Is it possible to connect my magento store to this api?
Magento by default does not support this and in my honest opinion I would not go down the route of doing this with magento. The best way I can see of doing this is the following;
1) Create a custom module with a cron config and model (http://www.magentocommerce.com/wiki/1_-_installation_and_configuration/how_to_setup_a_cron_job).
2) In the model you created and the method you defined in the module config, load your data feed and loop through the items. Either create them in magento if they don't exist or update/enable/disable/remove the product in magento if they do.
You can schedule the cron to run every few hours or more frequently if it's quick enough, well optimised and not too intensive. You can get clever and possibly have ajax stock check on product view page to give live stock on the product page. Or to ensure it is is in stock at time of order you could add an event observer for the checkout_cart_product_add_before and query the live stock to check it's actually there (but you need to create the event - magento did not create it Magento checkout_cart_product_add_before and get number of products added).
This will essentially allow you to keep magento working normally without extensively extending and overriding the core files. You could of course have a separate app altogether (maybe java) which does the same via magento's SOAP API and the the third party api.

How do you get a cart for a specific user using the Magento Core API?

I'm trying to show a cart icon in Drupal with the number of items in the cart of our sister Magento site.
I'm using the Magento Core API to look up information on customers and use it in Drupal. I'm trying to load the contents of the cart for a specific Magento Customer ID, but I don't see any way to do this. The cart info API method only supports look ups by quote ID. Quote ID appears to be the primary key for a cart.
Is it possible to look up cart information by customer ID with a Magento API?
You can't fetch this information using the Magento Core API, or even the new REST Api. If you wanted this information you'd need to write your own Magento extension and have it installed on the system you're targeting.
The "Cart" object in Magento ties a specific user account to a specific Magento "quote" object. A quote is an order before it's an order object. In Magento's "PHP API" (i.e. the native PHP objects Magento developers use to manipulate the system), this is a sales/quote object.
$quote = Mage::getModel('sales/quote');
Data for this object is stored in the the sales_flat_quote table, and there is a customer_id column so you should be able to get at the information you need.
The customer.info method does not return the active quote id for the customer according to the documentation, so it doesn't look like you can by default. It's pretty easy to extend the core API with a custom module to provide the quote id though. Or you could extend the checkout module and build a new api method that does the lookup by customer id instead and avoid the customer.info request all together. Have a read of http://www.magentocommerce.com/wiki/doc/webservices-api/custom-api for a guide on how to do this. Benefit of having a custom API method is that you can optimize it (Maybe do a query that gives you just the data you want (i.e. Just the number of products for the quote) instead of loading the full quote object).
P.S. Are you making the request for your drupal site by AJAX? I would as the API is slow and you don't want the drupal site hanging for a few seconds whilst you do the lookup.

Adding multiple items to OS Commerce cart programmatically / with API

I am creating a custom paintball marker configurator. The customers will be able to choose a marker, then add hundreds of different accessories with our html5 / java script configurator. The client has an OSCommerce site and the goal is to send all the pieces that make up their custom marker to the OScommerce cart.
All the pieces in the configurator will be in the oscommerce system, but we're going to build the configurator on codeigniter and a seperate html5 site. So my question is, is there any way to send information from another page on his site (our configurator) to the oscommerce cart.
I was thinking maybe an array of products with their specific information like sku number, product id, etc, and add that array to the oscommerce cart.
Any ideas? I can't find any solutions online. Thanks ahead of time!!!
http://forums.oscommerce.com/topic/45279-add-to-cart-from-external-page-or-site/
https://www.google.com/search?q=oscommerce+add+to+cart+from+external+site+site:forums.oscommerce.com
Looks like a nightmare TBH. Lots of issues with cookies/sessions. Might have to create a separate oscommerce file (e.g. custom_add_to_cart.php) to hit from the external page. Doesn't look like there's an easy way to add to cart > edit options on external page > save to cart. May be able to avoid some issues if you serve the html5 site on the same domain or create a custom page/module (if oscommerce has those).
Good luck!

Categories