G
G
Greg Popov2017-05-18 01:02:59
PHP
Greg Popov, 2017-05-18 01:02:59

How to upload products in OpenCart in batches?

There is a catalog of goods from VK, you need to fill them in a pack in OpenCart, I googled it, I didn’t find ready-made and free solutions (or I didn’t search well), maybe you can turn your head “in the right direction”
I would be grateful for your help. There is also a question with the same action on Facebook.

Answer the question

In order to leave comments, you need to log in

3 answer(s)
P
PrAw, 2017-05-18
@Gregpopov

1. get goods:
https://vk.com/dev/market.get
If there are problems with access to api (not enough rights) - create an application in VK, get its id and follow https://vk.com/ dev/implicit_flow_user
2. look at importing goods into opencart
starting from https://www.opencart.com/index.php?route=marketpla...
or any of your choice
3. chew goods from VK into the opencart goods format
4. unload .
In a particularly difficult case (as I did myself), a script is written for import. An example of shit code for version 1.5, this is enough if you do other actions with the product already in the admin panel - properties, categories, etc.:
ATTENTION: the database in the project, which is shown in this example, was heavily redrawn, as a result, the description, image fields were taken out of the related tables and inserted into this one (in the related models, I had to do the same). Lost the ability to store many photos, multilingualism. Received import of 100k goods in 10 seconds.
Thank you alex-1917 for your attention.

<?php
set_time_limit(0);
error_reporting(E_ALL);

include_once('config.php'); //конфиг админки
$my = new mysqli(DB_HOSTNAME, DB_USERNAME, DB_PASSWORD, DB_DATABASE);
$my->set_charset("utf8");

function addProduct($data,$my){
    foreach($data as $key=>$val)
    {
        $keys[] = '`'.$key.'`';
        $values[] = '"'.$my->real_escape_string($val).'"';
    }
    $keys[] = '`date_added`';   $values[] = 'NOW()';
    $keys[] = '`date_modified`';$values[] = 'NOW()';

    $keys2 = join(',',$keys);
    $vals2 = join(',',$values);

    $q = "INSERT INTO product ($keys2) VALUES ($vals2);";
    $my->query($q);
}


/*
$items - массив с товарами из вк, в каталоге data лежат файлы с картинками
*/

foreach($items as $item)
{
    $data = array();
    $data['category_id'] = 1; //всё в один раздел
    $data['name'] = $item['name'];
    $data['description'] = $item['description'];
    $data['articul'] = $item['articul'];
    $data['quantity'] = 1;
    $data['stock_status_id'] = 1;
    $data['manufacturer_id'] = 0;
    $data['shipping'] = 1;
    $data['price'] = 0;
    $data['tax_class_id'] = 0;
    $data['subtract'] = 1;
    $data['minimum'] = 1;
    $data['image'] = 'data/'.$item['image'];
    $cnt++;
    addProduct($data,$my);
}

B
Boris Korobkov, 2017-05-18
@BorisKorobkov

https://dev.mysql.com/doc/refman/5.7/en/insert.html

A
Artem Kaybagorov, 2017-05-18
@ArteMoon

https://opencartforum.com/files/file/3015-eksport-...

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question