abdou96 Posted April 29, 2023 Share Posted April 29, 2023 I want to add another column in the product page in the back office in prestashop 1.7.8.8 but the methods i found online are outdated or do not work , can someone give me a clue ? Link to comment Share on other sites More sharing options...
DARKF3D3 Posted May 14, 2023 Share Posted May 14, 2023 You mean admin product list? Link to comment Share on other sites More sharing options...
abdou96 Posted May 14, 2023 Author Share Posted May 14, 2023 yes , i found a way that lets you display the manufacturer name , but i want to display another table and can't find a way to display the data , i added the column by overriding the twig but it stays empty no matter what i did Link to comment Share on other sites More sharing options...
ps8modules Posted May 15, 2023 Share Posted May 15, 2023 Hi. Can you please be more specific, or add your code, or the table and column from which you need to show data? Link to comment Share on other sites More sharing options...
abdou96 Posted May 15, 2023 Author Share Posted May 15, 2023 <td class="text-center column-img-reduction"> {% if reduction is defined %} <a href="{{ reduction }}" target="_blank" > {{ reduction }}{{ reduction|default('') }}</a> {% else %} <h1> "reduction"</h1> {% endif %} </td> this is the collumn i added in list.html.twig <th scope="col"> {{ ps.sortable_column_header("reduction"|trans({}, 'Admin.Global'), 'reduct', orderBy, sortOrder) }} </th> and this is the collumn header i changed the query in AdminProductsController with a left join to retrieve the data from the specific table but it does not show anything and the collumn is empty Link to comment Share on other sites More sharing options...
ps8modules Posted May 16, 2023 Share Posted May 16, 2023 Hi. Reduction is read from the ps_specific_price table. There can be multiple conditions for a product, so you can't display just one item like this. Two items should be visible in the product list table. Link to comment Share on other sites More sharing options...
abdou96 Posted May 17, 2023 Author Share Posted May 17, 2023 I am actually trying to display a String called link from a table that i added , not a original Prestashop table and im using a join but the collumn is always empty <?php // ... public function hookActionAdminProductsListingFieldsModifier(array $params) { if ($this->isPrestaShop16) { if (isset($params['select'])) { $params['select'] .= ', a.id_product, cp.produit_lien AS produit_lien'; } if (isset($params['join'])) { $params['join'] .= ' LEFT JOIN ' . _DB_PREFIX_ . 'produit AS cp ON (a.id_product = cp.id_produit)'; } $params['fields']['produit_lien'] = [ 'title' => $this->l('Link'), 'align' => 'text-center', 'class' => 'fixed-width-xs', 'filter_key' => 'cp!produit_lien', 'order_key' => 'cp!produit_lien', ]; if (Configuration::get(static::CONFIGURATION_KEY_SHOW_LOGO)) { $params['fields']['produit_lien']['icon'] = true; $params['fields']['produit_lien']['class'] .= ' column-img-produit_lien'; } } else { $params['sql_select']['id_product'] = [ 'table' => 'p', 'field' => 'id_product', 'filtering' => ' %s ', ]; $params['sql_select']['produit_lien'] = [ 'table' => 'cp', 'field' => 'produit_lien', 'filtering' => 'LIKE \'%%%s%%\'', ]; $params['sql_table']['cp'] = [ 'table' => 'produit', 'join' => 'LEFT JOIN', 'on' => 'p.`id_product` = cp.`id_produit`', ]; $produit_filter = Tools::getValue('filter_column_produit'); if (!empty($produit_filter) && Validate::isCatalogName($produit_filter)) { $params['sql_where'][] .= sprintf('cp.produit_lien LIKE "%%%s%%"', pSQL($produit_filter)); } } } public function hookActionAdminProductsListingResultsModifier(array $params) { if (!Configuration::get(static::CONFIGURATION_KEY_SHOW_LOGO)) { return; } if ($this->isPrestaShop16 && !empty($params['list'])) { foreach ($params['list'] as $key => $fields) { if (isset($fields['id_product'], $fields['produit_lien'])) { $params['list'][$key]['produit_lien'] = [ 'src' => '../m/' . (int)$fields['produit_lien'], 'alt' => Tools::safeOutput($fields['produit_lien']), ]; } } } else { foreach ($params['products'] as $key => $product) { if ($product['id_product']) { $params['products'][$key]['produit_lien'] = $this->context->link->getMediaLink(_THEME_MANU_DIR_ . $product['produit_lien']); } } } } 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