Как импортировать из csv вес, ширину (упаковка)
lightman
Cпециалист
: 142
: 16-03-2011


11-09-2012 23:32
в товаре есть такие параметры - как их заполнить импортом из csv файла?

Ширина (упаковка): cm
Высота (упаковка): cm
Глубина (упаковка): cm
Вес (упаковка):
 
  
lightman
Cпециалист
: 142
: 16-03-2011


12-09-2012 14:15
я просто ненашел в стандартном импорте этих полей - хочется понять как же импортировать - не в ручную же прописывать :(
 
  
Алекс


Администратор
: 4516
: Красноярск
: 29-05-2009


12-09-2012 15:11
Откройте classes/Product.php

Замените стандартную функцию addProductAttribute на:

Код:
$minimal_quantity = 1

дописать:
Код:
, $depth = NULL

и после:
Код:
'quantity' => 0,

дописать:
Код:
, 'depth' => (float)($depth)


Итог:

Код:
public function addProductAttribute($price, $weight, $unit_impact, $ecotax, $quantity, $id_images, $reference, $supplier_reference, $ean13, $default, $location = NULL, $upc = NULL, $minimal_quantity = 1, $depth = NULL)
    {
        $price = str_replace(',', '.', $price);
        $weight = str_replace(',', '.', $weight);
        Db::getInstance()->AutoExecute(_DB_PREFIX_.'product_attribute',
        array('id_product' => (int)($this->id), 'price' => (float)($price), 'ecotax' => (float)($ecotax), 'quantity' => 0, 'depth' => (float)($depth),
        'weight' => ($weight ? (float)($weight) : 0), 'unit_price_impact' => ($unit_impact ? (float)($unit_impact) : 0),
        'reference' => pSQL($reference), 'supplier_reference' => pSQL($supplier_reference),
        'location' => pSQL($location), 'ean13' => pSQL($ean13), 'upc' => pSQL($upc), 'default_on' => (int)($default), 'minimal_quantity' => (int)$minimal_quantity),
        'INSERT');
        $id_product_attribute = Db::getInstance()->Insert_ID();
        Product::updateDefaultAttribute($this->id);
        if (!$id_product_attribute)
            return false;

        $this->addStockMvt((int)$quantity, 1, $id_product_attribute);

        if (empty($id_images))
            return (int)($id_product_attribute);
        $query = 'INSERT INTO `'._DB_PREFIX_.'product_attribute_image` (`id_product_attribute`, `id_image`) VALUES ';
        foreach ($id_images AS $id_image)
            $query .= '('.(int)($id_product_attribute).', '.(int)($id_image).'), ';
        $query = trim($query, ', ');
        if (!Db::getInstance()->Execute($query))
            return false;
        return (int)($id_product_attribute);
    }



Открыть tabs/AdminImport.php

после:
Код:
'weight' => array('label' => $this->l('Weight')),

дописать:
Код:
'depth' => array('label' => $this->l('Depth')),


после:
Код:
'weight' => 0,

дописать:
Код:
'depth' => 0,


после:
Код:
'weight' => array('label' => $this->l('Weight')),

дописать:
Код:
'depth' => array('label' => $this->l('Depth')),



Найти:
Код:
$id_product_attribute = $product->addProductAttribute((float)($info['price']), (float)($info['weight']), 0, (float)($info['ecotax']), (int)($info['quantity']), $id_image, strval($info['reference']), strval($info['supplier_reference']), strval($info['ean13']), (int)($info['default_on']), null, strval($info['upc']));

И заменить на:
Код:
$id_product_attribute = $product->addProductAttribute((float)($info['price']), (float)($info['weight']), 0, (float)($info['ecotax']), (int)($info['quantity']), $id_image, strval($info['reference']), strval($info['supplier_reference']), strval($info['ean13']), (int)($info['default_on']), null, strval($info['upc']), (float)($info['depth']));



И так далее для всех необходимых свойств.
 
  
lightman
Cпециалист
: 142
: 16-03-2011


12-09-2012 15:34
а модуля никакого нет - чтобы не править файлы и потом иметь возможность спокойного обновления движка?