
Being engaged in the development of online catalogs (or online stores) were faced with the problem of picking pictures for the product. Not every customer can afford to embed photographing every product into their processes (especially when there are more than 7000 of them), and does it make sense to photograph goods when their images are already on the Internet, and it is absolutely legal on manufacturers' websites. Manually downloading-uploading images is not an option. During the work we tried a lot of ways to "automate" this process:
- Unloading goods from 1C and synchronize images
- Uploading "wholesale" pictures via FTP
- Search for images using the Google API
Unloading goods from 1C and synchronize images
Situation: the shop sells second-hand and stock clothing. The problem is that there are no photos or it is very problematic to find them. Clothes come in trunks and in the store they don’t even know what is in them (they buy by weight).
The merchandise girl is engaged in acceptance, in the 1C database enters the data about the product. This item is placed on a table with a white background, above which is fixed a regular digital camera. Next, the girl presses a specially trained button in 1C, by clicking on it, an external application is launched that takes a picture of the product and saves the image to a folder, naming the file by article number.
')
Profit: the photo is stored in 1C, it is convenient for sellers to navigate the product. For example, a buyer comes from a site and says that he wants a product of a certain article or name, everything is clogged up in the 1C search, and in addition to a dry description, an image is also displayed. Now the girl knows the product in person and can easily find it in the sea of ​​other things. Second-hand same ...Let's get back to business. The folder on the local computer is synchronized with the server hosting the site. Next on the server, the images are resized to the desired size and stored in the right places. A separate song about how to resize 7000 pictures on a regular hosting, believe it is real.
As a result, we obtain a rather high automation of the whole process, which requires minimal human participation. Well, of course, all transactions, purchases, and sales in online are synchronized with 1C, since they began to flirt with it.
Uploading "wholesale" pictures via FTP
Everything is simpler, the situation is this: the customer has branded images; it’s simply not realistic to upload manually via the web interface, there are a lot of them, there are more than 5-6 additional images for each product. Do not be afraid, as a rule, manufacturers of goods provide its images, naming the files already by reference.
Pictures are simply uploaded to FTP, and the site knows where to find them. Everything is simple and clear.
Search for images using the Google API
Now the most interesting, as it seems to us. The situation is as follows: a store that sells offline famous brands (Grohe, Tarkett and other interior and finishing stuff) decided to start an online catalog of their products. As you can imagine, the images there play a crucial role. There are several thousand items in the store (about 15,000) and it is not yet possible to synchronize the site with the product database. At the entry of the goods will be allocated several specially trained monkeys. And it is clear that a person will look for a part of images on the Internet, save them, upload, etc. A very long time.
We found a simple and elegant way to upload images. Google provides its
Google Search AJAX API , it's a sin not to use it. It makes no sense to go into the technical implementation - everything is simple there.
The description of the product necessarily includes the brand and article, the specificity of this product (building stuff) is such that there is such a thing as a “Collection” - a set of goods. And after adding this data, a request is sent to the Google API, and it returns a JSON array with information about the images found. The images are shown to the “driver” and he chooses a suitable image to upload and bring it into the required format. In 90% of cases, pictures satisfy needs.
Everyone is happy ...
Let's not discuss on the topic of the legitimacy of using these images, let the choice remain on the conscience of the “driver”, since it chooses the source of the download and can visually determine whether this is a branded image or not. It should also be noted that the seller is the official representative of these brands in our city and he has the right to use images from manufacturers' sites.
We will not give links to sites, we are afraid of habraeffect, and PR of these resources is inappropriate here. Who cares - knock on PM.
UPDIn connection with a large number of questions in the PM, I post an example (our developments are made on ZendFramework, this code is just an example)
If you do not need AJAX, then everything is easier than ever.
http://ajax.googleapis.com/ajax/services/search/images?v=1.0&q=Philipino%20giveThere are additional options for filtering images.
PHP executes the request and the API returns the object in JSON format:
$query = ' ' ;
$body = file_get_contents( 'http://ajax.googleapis.com/ajax/services/search/images?v=1.0 &q=' .urlencode($query));
$json = json_decode($body);
foreach ($json->responseData->results as $result) {
echo '<img src="' . $result->tbUrl . '" title="' . $result->contentNoFormatting . '"/>' ;
}
* This source code was highlighted with Source Code Highlighter .
The result array contains a lot of useful information. The list of the most useful array keys:
- imageId - unique identifier of a picture
- url - screened url pictures
- width, height - the size of the picture
- tbWidth, tbHeight - preview sizes
- tbUrl - link to preview images
- title - picture description
Search news, blog, etc. works the same, but returns other array keys.
If you still need to search with AJAX, then there are already
good articles on this topic
.