hajar_rolin Posted October 11, 2022 Share Posted October 11, 2022 Je souhaite afficher les descriptions des produits sur ma liste de produits afin de pouvoir l'exporter. Ceci est ma requête SQL actuelle SELECT SQL_CALC_FOUND_ROWS p.`id_product` AS `id_product`, p.`reference` AS `reference`, sa.`price` AS `price`, p.`id_shop_default` AS `id_shop_default`, p.`is_virtual` AS `is_virtual`, pl.`name` AS `name`, pl.`link_rewrite` AS `link_rewrite`, sa.`active` AS `active`, shop.`name` AS `shopname`, image_shop.`id_image` AS `id_image`, cl.`name` AS `name_category`, 0 AS `price_final`, pd.`nb_downloadable` AS `nb_downloadable`, sav.`quantity` AS `sav_quantity`, IF(sav.`quantity`<=0, 1, 0) AS `badge_danger`, cp.`position` AS `position` FROM `ps_product` p LEFT JOIN `ps_product_lang` pl ON (pl.`id_product` = p.`id_product` AND pl.`id_lang` = 1 AND pl.`id_shop` = 1) LEFT JOIN `ps_stock_available` sav ON (sav.`id_product` = p.`id_product` AND sav.`id_product_attribute` = 0 AND sav.id_shop = 1 AND sav.id_shop_group = 0 ) JOIN `ps_product_shop` sa ON (p.`id_product` = sa.`id_product` AND sa.id_shop = 1) LEFT JOIN `ps_category_lang` cl ON (sa.`id_category_default` = cl.`id_category` AND cl.`id_lang` = 1 AND cl.id_shop = 1) LEFT JOIN `ps_category` c ON (c.`id_category` = cl.`id_category`) LEFT JOIN `ps_shop` shop ON (shop.id_shop = 1) LEFT JOIN `ps_image_shop` image_shop ON (image_shop.`id_product` = p.`id_product` AND image_shop.`cover` = 1 AND image_shop.id_shop = 1) LEFT JOIN `ps_image` i ON (i.`id_image` = image_shop.`id_image`) LEFT JOIN `ps_product_download` pd ON (pd.`id_product` = p.`id_product`) INNER JOIN `ps_category_product` cp ON (cp.`id_product` = p.`id_product` AND cp.`id_category` = 173) WHERE (1 AND state = 1) ORDER BY `id_product` desc LIMIT 0, 20 ; Avez-vous une suggestion? Merci Link to comment Share on other sites More sharing options...
Eolia Posted October 11, 2022 Share Posted October 11, 2022 pl.description, pl.description_short, Link to comment Share on other sites More sharing options...
hajar_rolin Posted October 11, 2022 Author Share Posted October 11, 2022 19 minutes ago, Eolia said: pl.description, pl.description_short, j'ai essayé mais rien a changé Comment je peux afficher la description dans la liste des produits Link to comment Share on other sites More sharing options...
Mediacom87 Posted October 11, 2022 Share Posted October 11, 2022 Bonjour, une piste https://devdocs.prestashop-project.org/1.7/modules/sample-modules/grid-and-identifiable-object-form-hooks-usage/ Link to comment Share on other sites More sharing options...
Knowband Plugins Posted October 12, 2022 Share Posted October 12, 2022 (edited) Utilisez le code ci-dessous pour exporter la description sans l'afficher dans la liste des produits Admin. CHANGEMENTS: 1. src\Adapter\Product\AdminProductDataProvider.php , getCatalogProductList() Add 'description' => ['table' => 'pl', 'field' => 'description'] , in $sqlSelect.Comme $sqlSelect = [ 'id_product' => ['table' => 'p', 'field' => 'id_product', 'filtering' => ' %s '], 'reference' => ['table' => 'p', 'field' => 'reference', 'filtering' => self::FILTERING_LIKE_BOTH], 'price' => ['table' => 'sa', 'field' => 'price', 'filtering' => ' %s '], 'id_shop_default' => ['table' => 'p', 'field' => 'id_shop_default'], 'is_virtual' => ['table' => 'p', 'field' => 'is_virtual'], 'name' => ['table' => 'pl', 'field' => 'name', 'filtering' => self::FILTERING_LIKE_BOTH], 'link_rewrite' => ['table' => 'pl', 'field' => 'link_rewrite', 'filtering' => self::FILTERING_LIKE_BOTH], 'active' => ['table' => 'sa', 'field' => 'active', 'filtering' => self::FILTERING_EQUAL_NUMERIC], 'shopname' => ['table' => 'shop', 'field' => 'name'], 'id_image' => ['table' => 'image_shop', 'field' => 'id_image'], 'name_category' => ['table' => 'cl', 'field' => 'name', 'filtering' => self::FILTERING_LIKE_BOTH], 'price_final' => '0', 'nb_downloadable' => ['table' => 'pd', 'field' => 'nb_downloadable'], 'sav_quantity' => ['table' => 'sav', 'field' => 'quantity', 'filtering' => ' %s '], 'description' => ['table' => 'pl', 'field' => 'description'] , 'badge_danger' => ['select' => 'IF(sav.`quantity`<=0, 1, 0)', 'filtering' => 'IF(sav.`quantity`<=0, 1, 0) = %s'], ]; 2. \src\Core\Product\ProductCsvExporter.php , export() Add 'description' => $this->trans('Description', 'Admin.Global'), in $headersData. Comme $headersData = [ 'id_product' => 'Product ID', 'image_link' => $this->trans('Image', 'Admin.Global'), 'name' => $this->trans('Name', 'Admin.Global'), 'reference' => $this->trans('Reference', 'Admin.Global'), 'name_category' => $this->trans('Category', 'Admin.Global'), 'price' => $this->trans('Price (tax excl.)', 'Admin.Catalog.Feature'), 'price_final' => $this->trans('Price (tax incl.)', 'Admin.Catalog.Feature'), 'sav_quantity' => $this->trans('Quantity', 'Admin.Global'), 'badge_danger' => $this->trans('Status', 'Admin.Global'), 'description' => $this->trans('Description', 'Admin.Global'), 'position' => $this->trans('Position', 'Admin.Global'), ]; Après cela, si vous exportez la liste de produits, une colonne "Description" est ajoutée dans le fichier CSV exporté. Edited October 12, 2022 by Knowband Plugins Wrong code shared (see edit history) 1 Link to comment Share on other sites More sharing options...
Mediacom87 Posted October 12, 2022 Share Posted October 12, 2022 Ce qui est fabuleux avec ce genre de pratique, c'est que l'on perd tout à la moindre mise à jour, c'est pour cela qu'il est toujours préférable d'intégrer ce genre de modification par le biais d'un module. Mais bon, après, cela permet de récupérer des clients en prestation pour rattraper ce genre de modification. 1 Link to comment Share on other sites More sharing options...
hajar_rolin Posted October 14, 2022 Author Share Posted October 14, 2022 (edited) On 10/12/2022 at 2:04 PM, Knowband Plugins said: Utilisez le code ci-dessous pour exporter la description sans l'afficher dans la liste des produits Admin. CHANGEMENTS: 1. src\Adapter\Product\AdminProductDataProvider.php , getCatalogProductList() Add 'description' => ['table' => 'pl', 'field' => 'description'] , in $sqlSelect.Comme $sqlSelect = [ 'id_product' => ['table' => 'p', 'field' => 'id_product', 'filtering' => ' %s '], 'reference' => ['table' => 'p', 'field' => 'reference', 'filtering' => self::FILTERING_LIKE_BOTH], 'price' => ['table' => 'sa', 'field' => 'price', 'filtering' => ' %s '], 'id_shop_default' => ['table' => 'p', 'field' => 'id_shop_default'], 'is_virtual' => ['table' => 'p', 'field' => 'is_virtual'], 'name' => ['table' => 'pl', 'field' => 'name', 'filtering' => self::FILTERING_LIKE_BOTH], 'link_rewrite' => ['table' => 'pl', 'field' => 'link_rewrite', 'filtering' => self::FILTERING_LIKE_BOTH], 'active' => ['table' => 'sa', 'field' => 'active', 'filtering' => self::FILTERING_EQUAL_NUMERIC], 'shopname' => ['table' => 'shop', 'field' => 'name'], 'id_image' => ['table' => 'image_shop', 'field' => 'id_image'], 'name_category' => ['table' => 'cl', 'field' => 'name', 'filtering' => self::FILTERING_LIKE_BOTH], 'price_final' => '0', 'nb_downloadable' => ['table' => 'pd', 'field' => 'nb_downloadable'], 'sav_quantity' => ['table' => 'sav', 'field' => 'quantity', 'filtering' => ' %s '], 'description' => ['table' => 'pl', 'field' => 'description'] , 'badge_danger' => ['select' => 'IF(sav.`quantity`<=0, 1, 0)', 'filtering' => 'IF(sav.`quantity`<=0, 1, 0) = %s'], ]; 2. \src\Core\Product\ProductCsvExporter.php , export() Add 'description' => $this->trans('Description', 'Admin.Global'), in $headersData. Comme $headersData = [ 'id_product' => 'Product ID', 'image_link' => $this->trans('Image', 'Admin.Global'), 'name' => $this->trans('Name', 'Admin.Global'), 'reference' => $this->trans('Reference', 'Admin.Global'), 'name_category' => $this->trans('Category', 'Admin.Global'), 'price' => $this->trans('Price (tax excl.)', 'Admin.Catalog.Feature'), 'price_final' => $this->trans('Price (tax incl.)', 'Admin.Catalog.Feature'), 'sav_quantity' => $this->trans('Quantity', 'Admin.Global'), 'badge_danger' => $this->trans('Status', 'Admin.Global'), 'description' => $this->trans('Description', 'Admin.Global'), 'position' => $this->trans('Position', 'Admin.Global'), ]; Après cela, si vous exportez la liste de produits, une colonne "Description" est ajoutée dans le fichier CSV exporté. Merci beaucoup, c'était ça la solution dont j'avais besoin Quand j'exporte mes produits j'obtiens un fichier csv de cette forme Est ce que vous avez un idée comment exporter les données correctement ? Merci d'avance Edited October 14, 2022 by hajar_rolin (see edit history) Link to comment Share on other sites More sharing options...
Knowband Plugins Posted October 17, 2022 Share Posted October 17, 2022 Il semble que le problème soit dû à une traduction. Avez-vous vérifié que le problème ne concerne qu'Excel ou tout autre logiciel. 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