2

What are the basic tables which need to use, so Product will be shown in Admin & Frontend as well?

No need for extra attribute/image as well. Required fields & Enabled Product.

As I seen below 2 tables required. Not sure about other tables

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

As I'm unable to import products from Backend. I'm thinking of alternatives.

Please re-confirm the above tables. This gonna be also tough. It's better someone can help with the Admin Side Product Import Issue

Magento 2: Product Import Error - Product Type is invalid or not supported. Duplicates found in column names [SOLVED]

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

8

As Admin side Import is not working. Have to follow this way to achieve functionality ASAP.

Managed to do below things, But 1 issue not able to Save on Admin side. I have compared table entry with other tables as well. Please point out what I'm missing

  1. catalog_product_entity // Main Product Table Entry

INSERT INTO catalog_product_entity (entity_id, attribute_set_id, type_id, sku, has_options, required_options, created_at, updated_at) VALUES (NULL, '16', 'simple', 'test1', '0', '0', CURRENT_TIMESTAMP, CURRENT_TIMESTAMP);

Will Return 2049 as Product Id & will be used for Future Tables

  1. catalog_product_entity_varchar // Title & Description & URL

INSERT INTO catalog_product_entity_varchar (value_id, attribute_id, store_id, entity_id, value) VALUES (NULL, '73', '0', '2049', 'Test 1'), (NULL, '84', '0', '2049', 'Test 1'), (NULL, '86', '0', '2049', 'Test 1'), (NULL, '126', '0', '2049', 'test-1');

  1. catalog_product_website // Assign Product to Website

INSERT INTO catalog_product_website (product_id, website_id) VALUES ('2049', '1');

  1. catalog_product_entity_decimal // Product Price

INSERT INTO catalog_product_entity_decimal (value_id, attribute_id, store_id, entity_id, value) VALUES (NULL, '77', '0', '2049', '1.11');

  1. catalog_product_index_price // Assign All Group Wise Price

INSERT INTO catalog_product_index_price (entity_id, customer_group_id, website_id, tax_class_id, price, final_price, min_price, max_price, tier_price) VALUES (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', NULL), (2049, 2, 1, 2, '1.1100', '1.1100', '1.1100', '1.1100', NULL), (2049, 3, 1, 2, '1.1100', '1.1100', '1.1100', '1.1100', NULL);

  1. catalog_category_product // Assign Product to Category

INSERT INTO catalog_category_product (entity_id, category_id, product_id, position) VALUES (NULL, '41', '2049', '1');

  1. catalog_product_entity_int // Enable Product & Visibility

INSERT INTO catalog_product_entity_int (attribute_id, store_id, entity_id, value) VALUES (133, 0, 2049, 2), (115, 0, 2049, 1), (99, 0, 2049, 4), (97, 0, 2049, 1);

  1. cataloginventory_stock_item // For Inventory Quantity

INSERT INTO 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) VALUES (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 // For URL Rewrite

INSERT INTO url_rewrite (entity_type, entity_id, request_path, target_path, redirect_type, store_id, description, is_autogenerated, metadata) VALUES ('product', 2049, 'coins/test-1.html', 'catalog/product/view/id/2049/category/41', 0, 1, NULL, 1, 'a:1:{s:11:"category_id";s:2:"41";}'), ('product', 2049, 'test-1.html', 'catalog/product/view/id/2049', 0, 1, NULL, 1, NULL);

Check the eav_attribute table which stores ALL Attributes

10] catalog_url_rewrite_product_category // For URL Rewrite

INSERT INTO catalog_url_rewrite_product_category (url_rewrite_id, category_id, product_id) VALUES ('631', '41', '2049');

After this, you are able to see your Product on the Frontend

Execute Below Command:

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

You can see your newly created product entry in Below tables now

catalog_category_product_index
catalog_product_flat_1
cataloginventory_stock_status
cataloginventory_stock_status_idx

Issue: When i go to Admin -> Catalog -> Edit Product & Save. It's not doing anything. Just Hold Over there. No Errors displayed on Admin or in Console no issue logged in Log file as well.

[UPDATE - Solution]

I'm using my new "Attribute Set" in that some of the Attributes are Mandatory fields.

I have added that attribute entry in catalog_product_entity_varchar & it's work fine now :)

0

Instancia de administrador de objetos

$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 productos/catalogos , y seleccionas el producto recien creado, al darle guardar, se habilita.

alquien tiene una solucion a esto. mi version de magento es 2.1

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.