тем, кто еще интересуется, как с помощью данного замечательного компонента импортировать свое добавочное (новодобавленное) поле товара. Ни на что не претендую, особо спецом не являюсь, хоть модули и сам делал, просто рассказываю что делал я и у меня это работает. (скопировано из моего личного сообщения для
dtokar по этому вопросу):
привет
Постараюсь подробнее рассказать что я делал для импорта дополнительно добавленного поля.
Само собой, речь идет о компоненте com_virtuemart_simple_csv, а ни о каком другом. Так же дополнительное поле для товара должно уже быть сделано в ВиртуеМарте и функционировать, то есть и нормально отображаться и быть в базе (jos_vm_product) и читаться/записываться. У меня это поле называется "Применяемость" (для какой техники применяется запчать, текстовое) с псевдонимом
product_applic в базе и переменной.
Извиняюсь, если перегибаю, возможно это все Вы и так знаете лучше меня.
Дальше.
1. Изменил установочный файл для базы "...\administrator\components\com_virtuemart_simple_csv\install.mysql.sql" -
добавил в самом конце строку
(94, 48, 'product_applic', '');
, не забываем про синтаксис, то естть в конце этой, последней строки запроса ставим ";". в конце предыдущей строки ",". Т.е. получаем в конце таакой примерно код:
(86, 48, 'category_id', ''),
(90, 48, 'additional_images', ''),
(91, 48, 'additional_files', ''),
(92, 48, 'price_for_group', ''),
(93, 48, 'product_currency', ''),
(94, 48, 'product_applic', '');
(можно потом заменить его в установочном архиве компонента и удалить/поставить заново, но лучше, все же наверное сделать как я делал - через PHPmyAdmin удалить таблицы компонента jos_virtuemart_simple_csv_aliases, jos_virtuemart_simple_csv_config,
jos_virtuemart_simple_csv_imagecache, а потом там же , в PHPmiAdmin выполнить скрипт из этого измененного файла - создать таблицы с уже нашим полем.)
2. Дальше я в файле "...\administrator\components\com_virtuemart_simple_csv\files\classes\ps_simple_csv.php"
после кода
//Fields jos_vm_product
$this->product_arr['product_publish'] = $db->f('product_publish');
$this->product_arr['product_sku'] = $product_sku;
$this->product_arr['product_name'] = $db->f('product_name');
$this->product_arr['product_url'] = $db->f('product_url');
$this->product_arr['vendor_id'] = $db->f('vendor_id');
$this->product_arr['product_tax_id'] = $db->f('product_tax_id');
$this->product_arr['product_s_desc'] = $db->f('product_s_desc');
$this->product_arr['product_desc'] = $db->f('product_desc');
$this->product_arr['product_in_stock'] = $db->f('product_in_stock');
$this->product_arr['product_availability'] = $db->f('product_availability');
$this->product_arr['image'] = $db->f('product_availability');
$this->product_arr['product_special'] = $db->f('product_special');
$this->product_arr['product_custom_attribute'] = $db->f('product_custom_attribute');
$this->product_arr['product_length'] = $db->f('product_length');
$this->product_arr['product_width'] = $db->f('product_width');
$this->product_arr['product_height'] = $db->f('product_height');
$this->product_arr['product_lwh_uom'] = $db->f('product_lwh_uom');
$this->product_arr['product_weight'] = $db->f('product_weight');
$this->product_arr['product_weight_uom'] = $db->f('product_weight_uom');
$this->product_arr['product_unit'] = $db->f('product_unit');
$this->product_arr['product_packaging'] = $db->f('product_packaging');
$this->product_arr['product_id'] = $db->f('product_id');
$this->product_arr['product_parent_id'] = $db->f('product_parent_id');
$this->product_arr['product_thumb_image_curr'] = $db->f('product_thumb_image');
$this->product_arr['product_full_image_curr'] = $db->f('product_full_image');
(это у меня строки 2056-2081)
добавил свое
$this->product_arr['product_applic'] = $db->f('product_applic');
3. В файле "...\administrator\components\com_virtuemart_simple_csv\helpers\emptyobjects\product.php"
после
var $product_arr = array (
'category_ids' => '',
'product_publish' =>"Y",
'product_sku' =>"",
'product_name' =>"",
'product_url' =>"",
'vendor_id' =>1,
'manufacturer_id' =>1,
'product_categories' => array (),
'product_price' =>"",
'product_price_id' =>NULL,
'price_quantity_start' =>"0",
'price_quantity_end' =>"0",
'product_currency' =>"",
'shopper_group_id' =>5,
'product_price_incl_tax' =>"",
'product_tax_id' =>"0",
'product_discount_id' =>"0",
'discounted_price_override' =>"",
'product_s_desc' =>"",
'product_desc' =>"",
'display_desc' =>"Y",
'desc_width' =>"",
'attrib_width' =>"",
'child_class_sfx' =>"",
'included_product_id' =>"",
'quantity_box' =>"none",
'quantity_start' =>"0",
'quantity_end' =>"0",
'quantity_step' =>"1",
'product_in_stock' =>"-1",
'min_order_level' =>"0",
'max_order_level' =>"0",
'product_available_date' => "",
'product_availability' =>"",
'image' =>"",
'product_special' =>"",
(строки 14-50)
добавил свое
Вроде так.
В настройках компонента "Настройки псевдонимов" ему затем так же присвоил product_applic => Применяемость.
Если ничего не забыл (пытался проверить все свои изменения поиском по слову "product_applic"), то именно после этого у меня нормально начало импортироваться это поле "Применяемость".
UPD4. Как в итоге выяснил - для того чтобы не затиралось значение вашего нового поля в случае, если в CSV-файле вы колонку этого нового поля решили вообще не указывать или удалили (например, решив, что оно никогда не поменяется) -
нужно так же и в файле "...\administrator\components\com_virtuemart\classes\ps_simple_csv.php" после кода:
//Fields jos_vm_product
$this->product_arr['product_publish'] = $db->f('product_publish');
$this->product_arr['product_sku'] = $product_sku;
$this->product_arr['product_name'] = $db->f('product_name');
$this->product_arr['product_url'] = $db->f('product_url');
$this->product_arr['vendor_id'] = $db->f('vendor_id');
$this->product_arr['product_tax_id'] = $db->f('product_tax_id');
$this->product_arr['product_s_desc'] = $db->f('product_s_desc');
$this->product_arr['product_desc'] = $db->f('product_desc');
$this->product_arr['product_in_stock'] = $db->f('product_in_stock');
$this->product_arr['product_availability'] = $db->f('product_availability');
$this->product_arr['image'] = $db->f('product_availability');
$this->product_arr['product_special'] = $db->f('product_special');
$this->product_arr['product_custom_attribute'] = $db->f('product_custom_attribute');
$this->product_arr['product_length'] = $db->f('product_length');
$this->product_arr['product_width'] = $db->f('product_width');
$this->product_arr['product_height'] = $db->f('product_height');
$this->product_arr['product_lwh_uom'] = $db->f('product_lwh_uom');
$this->product_arr['product_weight'] = $db->f('product_weight');
$this->product_arr['product_weight_uom'] = $db->f('product_weight_uom');
$this->product_arr['product_unit'] = $db->f('product_unit');
$this->product_arr['product_packaging'] = $db->f('product_packaging');
$this->product_arr['product_id'] = $db->f('product_id');
$this->product_arr['product_parent_id'] = $db->f('product_parent_id');
$this->product_arr['product_thumb_image_curr'] = $db->f('product_thumb_image');
$this->product_arr['product_full_image_curr'] = $db->f('product_full_image');
добавить для своего поля:
$this->product_arr['product_applic'] = $db->f('product_applic');
в итоге обновление файлом, не содержащим названия псевдонима этого моего поля product_applic перестало затирать значения этого поля.
Всем спасибо!
Отдельное спасибо Автору компонента -
Gruz!
Удачи!