Magento 2: Основные таблицы продуктов для отображения на стороне администратора и интерфейса [РЕШЕНО]


Какие основные таблицы необходимо использовать, чтобы продукт также отображался в интерфейсе администратора и интерфейса?

Также нет необходимости в дополнительном атрибуте/изображении. Обязательные поля и Включенный продукт.

Как я видел ниже, требуется 2 таблицы. Не уверен насчет других таблиц

catalog_product_entity
catalog_category_product
catalog_category_product_index
catalog_eav_attribute
catalog_product_website
catalog_product_entity_text
catalog_product_entity_varchar
catalog_product_entity_datetime
catalog_product_entity_decimal
catalog_product_entity_int
catalog_product_flat_1
catalog_product_index_price
cataloginventory_stock_item
cataloginventory_stock_status
cataloginventory_stock_status_idx
eav_entity_attribute
eav_attribute_option_value
url_rewrite

Так как я не могу импортировать продукты из серверной части. Я думаю об альтернативах.

Пожалуйста, подтвердите приведенные выше таблицы. Это тоже будет непросто. Лучше, если кто-то сможет помочь с Проблема импорта продукта на стороне администратора

Magento 2: Ошибка импорта продукта - Тип продукта недопустим или не поддерживается. Дубликаты, найденные в именах столбцов [РЕШЕНО]

Https://github.com/magento/magento2/issues/6939

Author: Rafael Corrêa Gomes, 2016-10-10

2 answers

Поскольку импорт на стороне администратора не работает. Нужно следовать этому пути, чтобы как можно скорее достичь функциональности.

Удалось сделать следующее, Но 1 проблема не удалось сохранить на стороне администратора. Я также сравнил запись в таблице с другими таблицами. Пожалуйста, укажите, чего мне не хватает

  1. catalog_product_entity//Запись в таблице Основных продуктов

ВСТАВИТЬ В catalog_product_entity (entity_id, attribute_set_id, type_id, sku, has_options, required_options, created_at, updated_at) ЗНАЧЕНИЯ (NULL, '16', 'простой', 'тест1', '0', '0', ОТМЕТКА ТЕКУЩЕГО ВРЕМЕНИ, ОТМЕТКА ТЕКУЩЕГО ВРЕМЕНИ);

Вернет 2049 в качестве идентификатора продукта и будет использоваться для будущих таблиц

  1. catalog_product_entity_varchar// Название, описание и URL-адрес

ВСТАВЬТЕ В catalog_product_entity_varchar (value_id, attribute_id, store_id, entity_id, value) ЗНАЧЕНИЯ (NULL, '73', '0', '2049', 'тест 1'), (нулевое, '84', '0', '2049', 'тест 1'), (null,с '86', '0', '2049', 'тест 1'), (нулевое, '126', '0', '2049', 'тест-1');

  1. catalog_product_website //Назначить продукт веб-сайту

ВСТАВИТЬ В catalog_product_website (product_id, website_id) ЦЕННОСТИ ('2049', '1');

  1. catalog_product_entity_decimal//Цена товара

ВСТАВЬТЕ В catalog_product_entity_decimal (value_id, attribute_id, store_id, entity_id, value) ЗНАЧЕНИЯ (NULL, '77', '0', '2049', '1.11');

  1. catalog_product_index_price//Назначить Всем Группам Разумную Цену

ВСТАВИТЬ В catalog_product_index_price (entity_id, customer_group_id, website_id, tax_class_id, price, final_price, min_price, max_price, tier_price) значения (2049, 0, 1, 2, '1.1100', '1.1100', '1.1100', '1.1100', значение null), (2049, 1, 1, 2, '1.1100', '1.1100', '1.1100', '1.1100', нуль), (2049, 2, 1, 2, '1.1100', '1.1100', '1.1100', '1.1100', нуль), (2049, 3, 1, 2, '1.1100', '1.1100', '1.1100', '1.1100', нуль);

  1. catalog_category_product//Назначить товар категории

ВСТАВИТЬ В catalog_category_product (entity_id, category_id, product_id, position) ЗНАЧЕНИЯ (NULL, '41', '2049', '1');

  1. catalog_product_entity_int// Включить продукт и видимость

ВСТАВЬТЕ В catalog_product_entity_int (attribute_id, store_id, entity_id, value) значения (133, 0, 2049, 2), (115, 0, 2049, 1), (99, 0, 2049, 4), (97, 0, 2049, 1);

  1. cataloginventory_stock_item//Для количества Запасов

ВСТАВИТЬ В cataloginventory_stock_item (item_id, product_id, stock_id, qty, min_qty, use_config_min_qty, is_qty_decimal, backorders, use_config_backorders, min_sale_qty, use_config_min_sale_qty, max_sale_qty, use_config_max_sale_qty, is_in_stock, low_stock_date, notify_stock_qty, use_config_notify_stock_qty, manage_stock, use_config_manage_stock, stock_status_changed_auto, use_config_qty_increments, qty_increments, use_config_enable_qty_inc, enable_qty_increments, is_decimal_divided, website_id) значения (2049, 2049, 1, '100.0000', '0.0000', 1, 0, 0, 1, '1.0000', 1, '10000.0000', 1, 1, значение null, '1.0000', 1, 1, 1, 0, 1, '1.0000', 1, 0, 0, 0);

  1. url_rewrite//Для перезаписи URL-адреса

ВСТАВЬТЕ В url_rewrite (entity_type, entity_id, request_path, target_path, redirect_type, store_id, description, is_autogenerated, metadata) значения ('продукт', 2049, 'coins/test-1.html', 'каталог/продукта/вид/код категории/2049//41', 0, 1, Значение null, 1, 'а:1:{с:11:"category_id";с:2:"41";}'), ('продукт, 2049, 'test-1.html', 'каталог/продукта/вид/код/2049', 0, 1, нуль, 1, нуль);

Проверьте eav_attribute таблицу, в которой хранятся ВСЕ атрибуты

10] catalog_url_rewrite_product_category // Для перезаписи URL-адреса

ВСТАВИТЬ В catalog_url_rewrite_product_category (url_rewrite_id, category_id, product_id) ЦЕННОСТИ ('631', '41', '2049');

После этого вы сможете увидеть свой продукт в Интерфейс

Выполните Следующую команду:

php bin/magento setup:upgrade
php bin/magento indexer:reindex
php bin/magento cache:flush

Теперь вы можете увидеть только что созданную запись о продукте в таблицах ниже

catalog_category_product_index
catalog_product_flat_1
cataloginventory_stock_status
cataloginventory_stock_status_idx

Проблема: Когда я перехожу к Admin -> Catalog -> Edit Продукту и сохраняю. Он ничего не делает. Просто держись вон там. Никаких ошибок, отображаемых администратором или в консоли, также не зарегистрировано в файле журнала.

[ ОБНОВЛЕНИЕ - Решение]

Я использую свой новый "Набор атрибутов" в том смысле, что некоторые атрибуты являются обязательными полями.

У меня есть добавил эту запись атрибута в catalog_product_entity_varchar, и теперь она работает нормально:)

 8
Author: Jackson, 2016-10-11 08:18:49

Инстанция управления объектами

$connection = new mysqli("localhost", "root", "usuario", "contraseña");

$tableName = 'catalog_product_entity'; //da el nombre de la tabla con prefijo
        /* insert a la base de datos*/
        //Insert Data into table
    $sql ="Insert Into ".$tableName."(attribute_set_id,type_id,sku,has_options,required_options,created_at,updated_at) Values ('16','simple','".$title."','0','0',CURRENT_TIMESTAMP,CURRENT_TIMESTAMP)";
    $connection->query($sql);

        //CONSULTA PARA SABER EL ID DE NEW PRODUCT
//$sql = "Select entity_id FROM ".$tableName." Where sku='".$title."' ORDER BY entity_id DESC LIMIT 1";
$ID_J = mysqli_insert_id($connection);
/*$r = $connection->query($sql); // gives associated array, table fields as key in array.
while($result = $r->fetch_object()){
    $ID_J = $result->entity_id;
}*/
//print_r($result);


    




$tableweb = 'catalog_product_website'; //da el nombre de la tabla con web
$sql3 ="Insert Into ".$tableweb." (product_id, website_id)Values('".$ID_J."','1')";
$connection->query($sql3);

$tableprecio = 'catalog_product_entity_decimal'; //da el nombre de la tabla de precio

//NEXO
$sql4_1 ="Insert Into ".$tableprecio." (attribute_id,store_id,entity_id,value)Values('77','0','".$ID_J."',".$price.")";
$connection->query($sql4_1);
$sql4_2 ="Insert Into ".$tableprecio." (attribute_id,store_id,entity_id,value)Values('78','0','".$ID_J."',NULL)";
$connection->query($sql4_2);
$sql4_3 ="Insert Into ".$tableprecio." (attribute_id,store_id,entity_id,value)Values('81','0','".$ID_J."',NULL)";
$connection->query($sql4_3);
$sql4_4 ="Insert Into ".$tableprecio." (attribute_id,store_id,entity_id,value)Values('82','0','".$ID_J."',NULL)";
$connection->query($sql4_4);
$sql4_5 ="Insert Into ".$tableprecio." (attribute_id,store_id,entity_id,value)Values('117','0','".$ID_J."',NULL)";
$connection->query($sql4_5);








$tablehabilitar ='catalog_product_entity_int'; //da el nombre de la tabla de habilitar producto
$sql5 ="Insert Into ".$tablehabilitar." (attribute_id,store_id,entity_id,value)Values('133','0','".$ID_J."','2')";
$connection->query($sql5);
$sql5_1 ="Insert Into ".$tablehabilitar." (attribute_id,store_id,entity_id,value)Values('97','0','".$ID_J."','1')";
$connection->query($sql5_1);
$sql5_2 ="Insert Into ".$tablehabilitar." (attribute_id,store_id,entity_id,value)Values('99','0','".$ID_J."','4')";
$connection->query($sql5_2);
// NEXO 
$sql5_3 ="Insert Into ".$tablehabilitar." (attribute_id,store_id,entity_id,value)Values('162','0','".$ID_J."','218')";
$connection->query($sql5_3);
$sql5_4 ="Insert Into ".$tablehabilitar." (attribute_id,store_id,entity_id,value)Values('93','0','".$ID_J."',NULL)";
$connection->query($sql5_4);
$sql5_5 ="Insert Into ".$tablehabilitar." (attribute_id,store_id,entity_id,value)Values('115','0','".$ID_J."','1')";
$connection->query($sql5_5);
$sql5_6 ="Insert Into ".$tablehabilitar." (attribute_id,store_id,entity_id,value)Values('141','0','".$ID_J."',NULL)";
$connection->query($sql5_6);
$sql5_7 ="Insert Into ".$tablehabilitar." (attribute_id,store_id,entity_id,value)Values('160','0','".$ID_J."','1')";
$connection->query($sql5_7);
$sql5_8 ="Insert Into ".$tablehabilitar." (attribute_id,store_id,entity_id,value)Values('142','0','".$ID_J."','0')";
$connection->query($sql5_8);
$sql5_9 ="Insert Into ".$tablehabilitar." (attribute_id,store_id,entity_id,value)Values('143','0','".$ID_J."','0')";
$connection->query($sql5_9);
$sql5_10 ="Insert Into ".$tablehabilitar." (attribute_id,store_id,entity_id,value)Values('144','0','".$ID_J."','0')";
$connection->query($sql5_10);
$sql5_11 ="Insert Into ".$tablehabilitar." (attribute_id,store_id,entity_id,value)Values('145','0','".$ID_J."','0')";
$connection->query($sql5_11);
$sql5_12 ="Insert Into ".$tablehabilitar." (attribute_id,store_id,entity_id,value)Values('146','0','".$ID_J."','0')";
$connection->query($sql5_12);
$sql5_13 ="Insert Into ".$tablehabilitar." (attribute_id,store_id,entity_id,value)Values('168','0','".$ID_J."','0')";
$connection->query($sql5_13);





$tablepro_index ='catalog_product_index'; //?????
$sql9 ="Insert Into ".$tablepro_index." (category_id,product_id,position,is_parent,store_id,visibility)
Values('2','".$ID_J."','0','0','1','4')";
$connection->query($sql9);
$sql9_1 ="Insert Into ".$tablepro_index." (category_id,product_id,position,is_parent,store_id,visibility)
Values('2','".$ID_J."','0','0','2','4')";
$connection->query($sql9_1);



$tablepro_i ='catalog_product_entity_text'; //?????
$sql9 ="Insert Into ".$tablepro_i." (attribute_id,store_id,entity_id,value)
Values('75','0','".$ID_J."',NULL)";
$connection->query($sql9);
$sql9_1 ="Insert Into ".$tablepro_i." (attribute_id,store_id,entity_id,value)
Values('76','0','".$ID_J."',NULL)";
$connection->query($sql9_1);
$sql9_2 ="Insert Into ".$tablepro_i." (attribute_id,store_id,entity_id,value)
Values('85','0','".$ID_J."',NULL)";
$connection->query($sql9_2);
$sql9_3 ="Insert Into ".$tablepro_i." (attribute_id,store_id,entity_id,value)
Values('103','0','".$ID_J."',NULL)";
$connection->query($sql9_3);
$sql9_4 ="Insert Into ".$tablepro_i." (attribute_id,store_id,entity_id,value)
Values('157','0','".$ID_J."',NULL)";
$connection->query($sql9_4);
$sql9_5 ="Insert Into ".$tablepro_i." (attribute_id,store_id,entity_id,value)
Values('158','0','".$ID_J."',NULL)";
$connection->query($sql9_5);
$sql9_6 ="Insert Into ".$tablepro_i." (attribute_id,store_id,entity_id,value)
Values('159','0','".$ID_J."',NULL)";
$connection->query($sql9_6);





$tablepro_date ='catalog_product_entity_datetime'; //?????
$sql10 ="Insert Into ".$tablepro_date." (attribute_id,store_id,entity_id,value)
Values('79','0','".$ID_J."',NULL)";
$connection->query($sql10);
$sql10_1 ="Insert Into ".$tablepro_date." (attribute_id,store_id,entity_id,value)
Values('80','0','".$ID_J."',NULL)";
$connection->query($sql10_1);
$sql10_2 ="Insert Into ".$tablepro_date." (attribute_id,store_id,entity_id,value)
Values('94','0','".$ID_J."',NULL)";
$connection->query($sql10_2);
$sql10_3 ="Insert Into ".$tablepro_date." (attribute_id,store_id,entity_id,value)
Values('95','0','".$ID_J."',NULL)";
$connection->query($sql10_3);
$sql10_4 ="Insert Into ".$tablepro_date." (attribute_id,store_id,entity_id,value)
Values('101','0','".$ID_J."',NULL)";
$connection->query($sql10_4);
$sql10_5 ="Insert Into ".$tablepro_date." (attribute_id,store_id,entity_id,value)
Values('102','0','".$ID_J."',NULL)";
$connection->query($sql10_5);




$tablepro_statu ='cataloginventory_stock_status'; //?????
$sql11 ="Insert Into ".$tablepro_statu." (product_id,website_id,stock_id,qty,stock_status)
Values('".$ID_J."',0,1,100,1)";
$connection->query($sql11);







$tprice = 'catalog_product_index_price'; //asignar precio
$sql8 ="Insert Into ".$tprice." (entity_id,  customer_group_id, website_id, tax_class_id, price,  final_price, min_price, max_price, tier_price)
Values(".$ID_J.", 0, 1, 2,".$price.",".$price.",".$price.",".$price.",NULL)";
$connection->query($sql8);
$sql8_1 ="Insert Into ".$tprice." (entity_id,  customer_group_id, website_id, tax_class_id, price,  final_price, min_price, max_price, tier_price)
Values(".$ID_J.", 1, 1, 2,".$price.",".$price.",".$price.",".$price.",NULL)";
$connection->query($sql8_1);
$sql8_2 ="Insert Into ".$tprice." (entity_id,  customer_group_id, website_id, tax_class_id, price,  final_price, min_price, max_price, tier_price)
Values(".$ID_J.", 2, 1, 2,".$price.",".$price.",".$price.",".$price.",NULL)";
$connection->query($sql8_2);
$sql8_3 ="Insert Into ".$tprice." (entity_id,  customer_group_id, website_id, tax_class_id, price,  final_price, min_price, max_price, tier_price)
Values(".$ID_J.", 3, 1, 2,".$price.",".$price.",".$price.",".$price.",NULL)";
$connection->query($sql8_3);









$tablestock = 'cataloginventory_stock_item'; //da el nombre de la tabla de precio
$sql6 ="Insert Into ".$tablestock." (item_id, product_id,  stock_id, qty, min_qty,  use_config_min_qty, is_qty_decimal,  backorders, use_config_backorders, min_sale_qty, use_config_min_sale_qty, max_sale_qty, use_config_max_sale_qty,  is_in_stock, low_stock_date, notify_stock_qty,  use_config_notify_stock_qty, manage_stock, use_config_manage_stock, stock_status_changed_auto,  use_config_qty_increments, qty_increments,  use_config_enable_qty_inc, enable_qty_increments,  is_decimal_divided, website_id)Values(".$ID_J.", ".$ID_J.", 1, '100.0000', '0.0000', 1, 0, 0, 1, '1.0000', 1, '10000.0000', 1, 1, NULL, '1.0000', 1, 1, 1, 0, 1, '1.0000', 1, 0, 0, 0)";
$connection->query($sql6);



function cortar_palabras($title, $largor = 20) 
{ 
   $palabras = explode(' ', $title); 
   if (count($palabras) > $largor) 
   { 
     return implode(' ', array_slice($palabras, 0, $largor)); 
   } else
         {
           return $title; 
         } 
} 

$f=cortar_palabras($title,7);

$url_t = str_replace(" ","-", $f);
$urlhtml = $url_t.".html<br>";



$tablurl = 'url_rewrite'; //url de producto
$sql7 ="Insert Into ".$tablurl." (entity_type, entity_id, request_path, target_path, redirect_type, store_id, description, is_autogenerated, metadata)
Values('product',".$ID_J.",".$url_t.",'catalog/product/view/id/".$ID_J."',0,1,NULL,1,NULL)";
$connection->query($sql7);

$sql7_1 ="Insert Into ".$tablurl." (entity_type, entity_id, request_path, target_path, redirect_type, store_id, description, is_autogenerated, metadata)
Values('product',".$ID_J.",".$urlhtml.",'catalog/product/view/id/".$ID_J."',0,2,NULL,1,NULL)";
$connection->query($sql7_1);



    //INSERT DE LAS SIGUIENTES TABLES

$tableimg = 'catalog_product_entity_varchar'; //da el nombre de la tabla con prefijo aqui se ubica img
$sql2 ="Insert Into ".$tableimg." (attribute_id,store_id,entity_id,value)
Values('73','0','".$ID_J."','".$title."')";
$connection->query($sql2);
$sql2_1 ="Insert Into ".$tableimg." (attribute_id,store_id,entity_id,value)
Values('84','0','".$ID_J."',NULL)";
$connection->query($sql2_1);
$sql2_2 ="Insert Into ".$tableimg." (attribute_id,store_id,entity_id,value)
Values('86','0','".$ID_J."',NULL)";
$connection->query($sql2_2);
$sql2_3 ="Insert Into ".$tableimg." (attribute_id,store_id,entity_id,value)
Values('126','0','".$ID_J."','".$url_t."')";
$connection->query($sql2_3);
$sql2_4 ="Insert Into ".$tableimg." (attribute_id,store_id,entity_id,value)
Values('106','0','".$ID_J."','container1')";
$connection->query($sql2_4);

//NEXO

$sql2_4_1 ="Insert Into ".$tableimg." (attribute_id,store_id,entity_id,value)
Values('118','0','".$ID_J."','0')";
$connection->query($sql2_4_1);
$sql2_4_2 ="Insert Into ".$tableimg." (attribute_id,store_id,entity_id,value)
Values('132','0','".$ID_J."','0')";
$connection->query($sql2_4_2);
$sql2_4_3 ="Insert Into ".$tableimg." (attribute_id,store_id,entity_id,value)
Values('100','0','".$ID_J."',NULL)";
$connection->query($sql2_4_3);
$sql2_4_4 ="Insert Into ".$tableimg." (attribute_id,store_id,entity_id,value)
Values('104','0','".$ID_J."',NULL)";
$connection->query($sql2_4_4);
$sql2_4_5 ="Insert Into ".$tableimg." (attribute_id,store_id,entity_id,value)
Values('114','0','".$ID_J."',NULL)";
$connection->query($sql2_4_5);
$sql2_4_6 ="Insert Into ".$tableimg." (attribute_id,store_id,entity_id,value)
Values('116','0','".$ID_J."',NULL)";
$connection->query($sql2_4_6);
$sql2_4_7 ="Insert Into ".$tableimg." (attribute_id,store_id,entity_id,value)
Values('134','0','".$ID_J."',NULL)";
$connection->query($sql2_4_7);
$sql2_4_8 ="Insert Into ".$tableimg." (attribute_id,store_id,entity_id,value)
Values('136','0','".$ID_J."',NULL)";
$connection->query($sql2_4_8);
$sql2_4_9 ="Insert Into ".$tableimg." (attribute_id,store_id,entity_id,value)
Values('149','0','".$ID_J."',NULL)";
$connection->query($sql2_4_9);
$sql2_5 ="Insert Into ".$tableimg." (attribute_id,store_id,entity_id,value)
Values('150','0','".$ID_J."',NULL)";
$connection->query($sql2_5);
$sql2_5_1 ="Insert Into ".$tableimg." (attribute_id,store_id,entity_id,value)
Values('151','0','".$ID_J."',NULL)";
$connection->query($sql2_5_1);
$sql2_5_2 ="Insert Into ".$tableimg." (attribute_id,store_id,entity_id,value)
Values('152','0','".$ID_J."',NULL)";
$connection->query($sql2_5_2);
$sql2_5_3 ="Insert Into ".$tableimg." (attribute_id,store_id,entity_id,value)
Values('153','0','".$ID_J."',NULL)";
$connection->query($sql2_5_3);
$sql2_5_4 ="Insert Into ".$tableimg." (attribute_id,store_id,entity_id,value)
Values('161','0','".$ID_J."',NULL)";
$connection->query($sql2_5_4);
$sql2_5_5 ="Insert Into ".$tableimg." (attribute_id,store_id,entity_id,value)
Values('163','0','".$ID_J."',NULL)";
$connection->query($sql2_5_5);

Se crea el produto perfectamente, pero al realizar una busqueda en el frontend no se muestra, PERO al entrar en el administrador продукты/каталоги, y seleccionas el producto recien creado, аль дарле гуардар, юная абилита.

Alquien tiene una решение проблемы. mi версия de magento es 2.1

 0
Author: Juan José Obispo, 2020-11-06 10:52:05