What`s the best practice for Magento to update stock from code - api

I have to integrate my webshop with an external system. This system provides several functionalities, described in their API. This is what I want to do:
Import/sync products (this is available as CSV via request)
Update stock of products (also available as webrequest)
So I have to hook into the Magento stock check and I want some script which updates the products like everyday.
Where should I implement my changes? What is the best way to do this? I can imagine Magento already have some API stock functionalities, but can`t seem to find the right documentation.
Thanks in advance!

Firstly you could use the Magento web service via either SOAP and XML-RPC:
http://www.magentocommerce.com/api/soap/introduction.html#Introduction-SOAP
There's an API for updating stock levels:
http://www.magentocommerce.com/api/soap/catalogInventory/cataloginventory_stock_item.update.html
However, this is usually quite slow and can take some time to update large collections of products, in which case you are better going for a solution which uses the Magento object model directly, or something custom.
Depending upon your level of development expertise there's a few options available. One library to checkout is Magmi:
http://sourceforge.net/apps/mediawiki/magmi/index.php?title=Magmi_Wiki
this is useful for updating lots of product data / stock levels quite quickly.
If you do no require an automated solution, you could always use the standard Magento import/export profiles to import stock levels from a CSV file, a quick search for 'Magento Import Export Profiles' should give you a good starting place:
http://www.seenbest-web-design.com/techclub/importing-a-csv-of-products-to-magento/
http://www.woolleydesign.net/2011/02/updating-store-inventory-in-magento/

I am fully functionally using Magmi now. I have written a plugin to automatically create configurable products, so if anyone is ever interested let me know.
There is already a plugin to process configurable products, my plugin is dependent on that plugin.
Basically, you will only be able to create configurable products if you especially have added this to your CSV, with a column named 'type'. In the column type you can set simple or configurable. With my module that won`t be nessecary. By some logic I automatically recognize the simple products and create a new configurable containing those products.
A little explanation on why I need this:
The stock system of our client updates a list of product (CSV) every few hours, containing entries of products. They sell clothing, and every size, and every color is a new entry. So one product can have 10 entries, entry 1: t-shirt green, size 12; entry 2: t-shirt green, size 13, etc.
I explain this, just in case anybody would ever need something like this, my plugin will probably help you. It will although need a few modification for your situation, since this is very specific to how your list of products is composed.
Anyway, thanks for your help!

Related

Set Woocommerce product attributes

everyone,
I have a "small" problem here for which I have not yet found a suitable solution. I hope you have the right food for thought for me.
We are currently in the process of introducing a new ERP (Weclapp - www.weclapp.com), which will transfer the product data to Woocommerce via ERP's own API. Many of our products are quite similar and available in different versions (industrial parts with different alloys, angles, sizes, etc.). Our product range includes tens of thousands of different products, so it is essential to offer the user a filtering option. Although it would be possible to create a variant article in the ERP, we would like to avoid this if possible (due to the circumstances that this would create on the part of the ERP). Unfortunately, the API does not allow us to transfer product attributes directly to single articles. The API only offers the possibility to transfer your own fields (created in the ERP) and output them in Woocommerce in the tab "Additional Information" or alternatively to fill an existing field in Woocommerce (can also be a custom field) via Meta Data Key.
I found the Meta Data Key for the product attributes, but I only have the possibility to transfer simple values like "Stainless Steel", "180°", "2SN" etc. The Meta Data Key for the product attributes looks a bit more cryptic and would be replaced by the simple values.
Does anyone have an idea or a workaround how I can use the values of the additional fields of the ERP as filterable data in Woocommerce?
Thanks a lot already!

Could Prestashop be used to build a craigslist clone?

I'm not so much interested in actually doing this as knowing if Prestashop has the power to allow members to create their own products, classifieds, etc. I've read some articles on Prestashop and played around with it a bit and it looks like the shop owner has to do all the creating and the users consume.
To make client add there own products etc. using prestashop you need to promote all of them at least to managers and grant access to back-office.
But prestashop is just framework as all CMS are. If you have plenty amount of time it is possible to make everything using prestashop source code...
... question is: is it worth?
Especially with the addition of the Webservice in Prestashop 1.4 onwards there's no reason why you couldn't write your own simple "control panel" to give ordinary users some capabilities for creating and managing their own "products".
Obviously you would need to add your own permission scheme (including "ownership") for the products they created, as well as creating the actual product create/edit front end for them.
Definitely possible but non-trivial.
Paul

Setting carrier per product

I'm working on a store that has two types of products: perishable food and general merchandise. The food must always be shipped overnight via FedEx, and the other merchandise must always be shipped via USPS. If somebody orders products from both categories, they must be shipped separately.
Do you know of an existing module or configuration settings that would allow for this?
If not, it sounds like a custom module would be the other solution. In this case, what is the best approach? I'm thinking it would be splitting the order into a multi-address shipment, using the same address for both but with different shipping methods. Unfortunately I'm not sure how to do this programatically, so any tutorials/samples/resources would be greatly appreciated.
Probably the sanest way to handle this would be to create two orders per product type, each shipping with a different carrier to the same address. This also IMO makes more sense from a stores tracking perspective as you can handle each independently from each other.
To get you on the right track(since Magento is especially cryptic in this part of itself) you should read the Inchoo programmatically create order in Magento post and by the same author Programatically create customer and order in Magento with full blown one page checkout.
Basically as I see this going is:
Get the customer order
Itinerate through each product inside the order and split it up in two arrays for each product type
Create a separate order for each product type and use the different shipping methods for each.
You will probably have to extend a some controllers OR do it the non-standard way and use helper functions for this, the hard parts will be integrating the payment/shipping modules inside your order process. Going this way will have you creating the full checkout process as the one page checkout Magento provides won't really work and is too much pain to get to work because of the way it uses AJAX.
Also another alternative is to hook in to Magento's pre-create order events and create the orders there using already defined order data split it up in two orders, but this is something I never heard or saw implemented at the moment so you'd have to do it "blindfolded" so to speak.
An easier approach would be to use a custom field that defines your product's shipping method, this way you just add that and don't care about custom orders. You just react with that, however tracking will become mostly impossible IMO.
Over-ride the Free Shipping module.
You can setup a sales rule that applies to certain products and makes them 'Free Shipping', leaving the other products to your chosen main shipment provider.
You will need to see how this works, however, the point is that Magento does have something built in to split an order into two shipping categories, albeit only a sales rule on free shipping. But you have source code...

"Dynamic" Pricing System

Soon I'll be working on a project that amounts to what is essentially an e-commerce app for configured products. This question is about ways to implement pricing schemes that can change from day to day, so we want to get the pricing logic out of code and into a database, but not in a way that causes the database to do all the work.
The basic idea is this, there are 5 attributes. You pick an option from each of those attributes. Then you start adding products to your cart. All the product you add will have those 5 attributes tacked onto them (the attributes will affect the pricing). Once you've added a product, you can apply modifications to it (the attributes will also be applied to the modifications).
So, what we've got at this point is a product (which has a fixed base price) with some information about it (that will modify the price), and zero or more modifications (which has a fixed price) and some information about them (which will modify the price). Modifications can also incur additional charges. For instance, if company A uses this software and they price their items using: BASE_PRICE + $50 * NUM_WHIRLIGIGS and the item has a modification that adds a WHIRLIGIG, that will have to be reflected in the price.
Do you know of any examples of different pricing systems that I might find useful when determining how to set this up? Do you have better ideas?
My current best thought is below, you can skip it if you're not curious about the particulars of the method and just want to get right to the answering!
For any given item (or collection of items) the company could use a special interface to set up pricing formulas which would then be interpreted and evaluated at run-time.
So for PRODUCT_A, the company might put in something like BASE_PRICE + WHIRLIGIG_UPCHARGE * NUM_WHIRLIGIGS. And the software, when it comes time to price it, would look at how many WHIRLIGIGS the item has, as well as how many WHIRLIGIGS are added by any modifications.
Does anyone have experience implementing this kind of interpreter? How did it turn out? Was it difficult/troublesome?
Thanks in advance for all the awesome input I'll sure I'll get. :P
Typically, this is usually handled with product bundles which have components. So a product with 5 additional subcomponents would not be base + 5 * addon, but SUM(base, addon, addon, addon, addon, addon).
So your product table may either be self-referential or there is some kind of link table which says which sub-products are allowed to be attached to which products.
In my experience, pricing is usually stored on a product/customer or contract basis, so that's another table.
Then the actual orders themselves contain product bundles. If the order is a quote, then the pricing is frozen (up to the expiration of the quote).
When an quote or order is turned into an invoice, at that time the pricing is either locked in from the main pricing or the quote, depending upon the pricing timing paradigm.

Is there a way to get details of the product from single insudtry?

I want to maintain a database of all the products or the brands with respect to industry.
For example I need to get information about all the food supplements. How can I get them?
I am not sure all the companies have an API for their products.
Please advise
Uhm,... what kind of information? If you need prices, you can probably get information from goverment sources. At least you can here in Argentina. Other than that, I don't think it's possible, unless you somehow manage to scrape websites of all the brands you want to track.
Speaking as someone who has worked for two data-aggregation companies, aggregating data involves a lot of manual work. You find the sources, you automate the acquisition of data as best you can (APIs, file downloads and imports, even screen scraping from HTML pages), and you stay on top of it constantly. You're always looking for additional sources, updating code for sources that have changed, minding legal implications of sources who don't want you to harvest their data, etc.
Sometimes you have to buy the data, or weigh that cost against not having data from that source or scraping it manually. Sometimes a source will block you in some way and you need to either try to get around that or negotiate some terms with them. It's a viable business model, but it's not cheap.
For some products, Retailigence ( http://www.retailigence.com ) may have data in API form. They basically keep track of local stores' inventory and pricing for certain categories of products.
You should definitely check out Good Guide - an API that gives you access to details on over 60,000 household products.
http://developer.goodguide.com
DailyMed is a good service to check out if you're interested in products in the medical space.
http://dailymed.nlm.nih.gov/dailymed