GeoPixel Posted September 4, 2019 Share Posted September 4, 2019 (edited) Buenos días, Estoy realizando una importación de productos por .CSV mediante un script en php. La importación se realiza correctamente con todos los campos menos las imagenes. Dejo el código de la importación al final de la consulta. Las imagenes las inserto mediante URL ( https://www.URL.com/resources/img/products/28231g.jpg ) Debo añadir algo al script para que se importen las imagenes o es necesario tocar alguna otra cosa para que me las reconozca? <?php header("Content-Type: text/html;charset=utf-8"); ini_set('display_errors', 1); ini_set('display_startup_errors', 1); error_reporting(E_ALL); define('_PS_ADMIN_DIR_', getcwd()); //include_once(_PS_ADMIN_DIR_ . '/../config/settings.inc.php'); include_once(_PS_ADMIN_DIR_ . '/../config/config.inc.php'); use PrestaShop\PrestaShop\Core\Import\Configuration\ImportConfigInterface; use PrestaShop\PrestaShop\Adapter\Tools; use PrestaShop\PrestaShop\Core\ConfigurationInterface; use PrestaShop\PrestaShop\Core\Hook\HookDispatcherInterface; use Tools as LegacyTools; $context = Context::getContext(); $employee = new Employee(1); $context->employee = $employee; function loadProductsPost() { $_POST = array ( 'tab' => 'AdminImport', 'forceIDs' => '0', 'skip' => '1', 'csv' => 'productos.csv', 'entity' => '1', 'separator' => ';', 'multiple_value_separator' => ',', 'iso_lang' => 'es', 'convert' => '', 'import' => 'Importar datos csv', 'type_value' => array( 0 => 'id', 1 => 'active', 2 => 'no', //revisar 3 => 'category', 4 => 'price_tex', 5 => 'id_tax_rules_group', 6 => 'on_sale', 7 => 'reduction_price', 8 => 'reduction_percent', 9 => 'reduction_from', 10 => 'reduction_to', 11 => 'reference', 12 => 'supplier_reference', 13 => 'supplier', 14 => 'ean13', 15 => 'height', 16 => 'width', 17 => 'depth', 18 => 'weight', 19 => 'quantity', 20 => 'no', 21 => 'minimal_quantity', 22 => 'no', 23 => 'no', 24 => 'description', 25 => 'no', 26 => 'no', 27 => 'no', 28 => 'meta_title', 29 => 'no', 30 => 'no', 31 => 'no', 32 => 'image', 33 => 'customizable', 34 => 'visibility', 35 => 'delivery_time', 36 => 'features', 37 => 'no', 38 => 'no', 39 => 'no', 40 => 'no', 41 => 'manufacturer', ), ); } $import = New AdminImportControllerCore(); loadProductsPost(); $import->productImport(); echo ('ejecutado'); ?> Edited September 4, 2019 by GeoPixel (see edit history) Link to comment Share on other sites More sharing options...
GeoPixel Posted September 4, 2019 Author Share Posted September 4, 2019 Lo he podido solucionar definitivamente. Dejo el resultado por si a alguien le sirve... He creado un override de AdminImportController.php y en la función de productImportOne, he añadido siguiente comprobación: if (isset($product->image) && !is_array($product->image)) { $product->image = explode(",", $product->image); } if (isset($product->image) && !is_array($product->image_alt)) { $product->image_alt = explode(",", $product->image_alt); } Link to comment Share on other sites More sharing options...
Luisejo Posted September 4, 2019 Share Posted September 4, 2019 Hola GeoPixel, Muchas gracias por compartir el dato. Si puedes, edita el título de este hilo y añade [SOLUCIONADO] al principio para que todos sepamos que está aclarado. Gracias. Link to comment Share on other sites More sharing options...
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now