December 16, 20178 yr From the PS forum I have extended the product list with the columns for manufacturers and suppliers. Adapted to TB programming. Either: controllers / admin / AdminProductsController.php or via override override / controllers / admin / AdminProductsController.php As an an example (german text on image): The customized file 01513384537636AdminProductsController.php
December 16, 20178 yr Author @lesley Sorry, there is someone on the line with me. I don't understand what you mean by that.
December 16, 20178 yr Author Here you can see the changed code. If it is not completely needed, you can eg omit the lines and the array for the manufacturer or the supplier. original part 1 ``` $idShop = Shop::isFeatureActive() && Shop::getContext() == Shop::CONTEXTSHOP ? (int) $this->context->shop->id : 'a.idshopdefault'; $this->join .= ' JOIN '._DB_PREFIX_.'product_shop sa ON (a.id_product = sa.id_product AND sa.idshop = '.$idShop.') LEFT JOIN '._DB_PREFIX_.'category_lang cl ON ('.$alias.'.id_category_default = cl.id_category AND b.id_lang = cl.id_lang AND cl.idshop = '.$idShop.') LEFT JOIN '._DB_PREFIX_.'shop shop ON (shop.idshop = '.$idShop.') LEFT JOIN '._DB_PREFIX_.'image_shop imageshop ON (imageshop.id_product = a.id_product AND imageshop.cover = 1 AND imageshop.idshop = '.$idShop.') LEFT JOIN '._DB_PREFIX_.'image i ON (i.id_image = image_shop.id_image) LEFT JOIN '._DB_PREFIX_.'product_download pd ON (pd.id_product = a.id_product AND pd.active = 1)'; new $idShop = Shop::isFeatureActive() && Shop::getContext() == Shop::CONTEXTSHOP ? (int) $this->context->shop->id : 'a.idshopdefault'; $this->join .= ' JOIN '._DB_PREFIX_.'product_shop sa ON (a.id_product = sa.id_product AND sa.idshop = '.$idShop.') LEFT JOIN '._DB_PREFIX_.'category_lang cl ON ('.$alias.'.id_category_default = cl.id_category AND b.id_lang = cl.id_lang AND cl.idshop = '.$idShop.') LEFT JOIN '._DB_PREFIX_.'shop shop ON (shop.idshop = '.$idShop.') LEFT JOIN '._DB_PREFIX_.'image_shop imageshop ON (imageshop.id_product = a.id_product AND imageshop.cover = 1 AND imageshop.idshop = '.$idShop.') LEFT JOIN '._DB_PREFIX_.'image i ON (i.id_image = imageshop.id_image) LEFT JOIN '._DB_PREFIX_.'manufacturer m ON (m.id_manufacturer = a.id_manufacturer) LEFT JOIN '._DB_PREFIX_.'supplier supp ON (supp.idsupplier = a.id_supplier) LEFT JOIN '._DB_PREFIX_.'product_download pd ON (pd.id_product = a.id_product AND pd.active = 1)'; ``` original part 2 $this->_select .= 'shop.`name` AS `shopname`, a.`id_shop_default`, '; $this->_select .= $aliasImage.'.`id_image` AS `id_image`, cl.`name` AS `name_category`, '.$alias.'.`price`, 0 AS `price_final`, a.`is_virtual`, pd.`nb_downloadable`, sav.`quantity` AS `sav_quantity`, '.$alias.'.`active`, IF(sav.`quantity`<=0, 1, 0) AS `badge_danger`'; new $this->_select .= 'shop.`name` AS `shopname`, a.`id_shop_default`, '; $this->_select .= 'm.`name` AS `manufacturer_namen`, '; $this->_select .= 'shop.name as shopname, supp.`name` AS `supp`, '; $this->_select .= $aliasImage.'.`id_image` AS `id_image`, cl.`name` AS `name_category`, '.$alias.'.`price`, 0 AS `price_final`, a.`is_virtual`, pd.`nb_downloadable`, sav.`quantity` AS `sav_quantity`, '.$alias.'.`active`, IF(sav.`quantity`<=0, 1, 0) AS `badge_danger`'; original part 3 ``` $this->fieldslist['active'] = [ 'title' => $this->l('Status'), 'active' => 'status', 'filterkey' => $alias.'!active', 'align' => 'text-center', 'type' => 'bool', 'class' => 'fixed-width-sm', 'orderby' => false, ]; if ($joinCategory && (int) $this->id_current_category) { $this->fields_list['position'] = [ 'title' => $this->l('Position'), 'filter_key' => 'cp!position', 'align' => 'center', 'position' => 'position', ]; ``` new ``` $this->fieldslist['active'] = [ 'title' => $this->l('Status'), 'active' => 'status', 'filterkey' => $alias.'!active', 'align' => 'text-center', 'type' => 'bool', 'class' => 'fixed-width-sm', 'orderby' => false, ]; $this->fields_list['manufacturer_namen'] = [ 'title' => $this->l('Manufacturer'), 'filter_key' => 'm!name', 'orderby' => true, ]; $this->fields_list['supp'] = [ 'title' => $this->l('Supplier'), 'filter_key' => 'supp!name' ]; if ($joinCategory && (int) $this->id_current_category) { $this->fields_list['position'] = [ 'title' => $this->l('Position'), 'filter_key' => 'cp!position', 'align' => 'center', 'position' => 'position', ]; ```
November 2, 20188 yr this is working but not if I try to override it. :( I would like to override, @zimmer-media is your code working override in 1.0.7? p.s. Overrides are not disabled in "performance"
November 5, 20188 yr I cloned the original file AdminProductsController.php, modified as instructions and copied in the directory: override/controllers/admin/ Permissions are correct.
November 5, 20188 yr Well what is your classname with extending? Have you deleted class_index.php in cache directory?
November 5, 20188 yr I have no cache active Why not? PageCache has its flaws, but the other cache systems should work just fine. Even for development I keep Smarty cache turned on, with "recompile if something has changed".
November 5, 20188 yr @traumflug said in Product list BO with manufacturers and suppliers columns: Why not? PageCache has its flaws, but the other cache systems should work just fine. Even for development I keep Smarty cache turned on, with “recompile if something has changed”. It's a sandbox. I have no TB installation in production right now. I'm going to follow your advice for "recompile if something has changed".
June 19, 20197 yr Ok I was looking at this from Nemo's website. Which he did the core file in his demo. This post helped me figure out how to do the override.. Now the question is and I think I know the answer. How do you do Multiple overrides to the same controller? Example I have a module that needs to write out config to the Overridden file but it can't. So in general you are you only allowed to override one controller one time or only in on file named the same thing? Example controllers / admin / AdminProductsController.php or via override override / controllers / admin / AdminProductsController.php we do this Manufacturer Change. The module wants to write to same file name. It can't. It seems you can't just create the file named / controllers / admin / AdminProductsControllerMan.php then create the class inside the file as. class AdminProductsControllerMan extends AdminControllerCore Or can you and I am doing it incorrectly? Not a coder.
June 19, 20197 yr It's really hard to understand your question. Not sure if I got it right. You want to use AdminProductsController.php in the override folder and in a module? I dont know what happens when multiple "places" try to override it. Once I read, that ps was trying to combine this files into one. Not sure if this is still true. Maybe @Traumflug can answer it!? But in general I believe you are using too much overrides. In a module I try to avoid every override. I only use override very few times if I really need to change the core. What are you tryiing to achieve? If you want to change lists from a module, you can use some hooks like hookActionAdminProductsListingFieldsModifier.
June 19, 20197 yr I bet. It's hard to explain since I don't fully understand what overrides are for and their limitations. Let me try again. We will use the Manufacturer example. The core system doesn't have this feature in it already E.G. you can't filter by manufacturer. Since its not in the Core system we have 2 choices add it to the core file or create and override? The first not a good solution since core files are overwritten by upgrade. So that leaves us with Overrides. (Of course the other option is have it added by someone to the core system.) So we do the override and it works.. All is great until... We need to add more functionality to the same Controller E.G. AdminProductsController.php . How do we do this safely and correctly? Are we allowed to create AdminProductsController2.php , AdminProductsController3.php and so on? In short how do we best add more functionality to the system. Edited June 19, 20197 yr by Factor
June 19, 20197 yr 4 hours ago, Factor said: add it to the core file or create and override? Create override if no other solution is there. Never change core files. -> You got that right. 4 hours ago, Factor said: We need to add more functionality to the same Controller E.G. AdminProductsController.php . How do we do this safely and correctly? There is no need for a second file. As you can make all changes in this one file. Are you talking about the same function or different function? You can add different function into the override. You can even add function which aren't in the original core file.
June 19, 20197 yr 2 minutes ago, wakabayashi said: Never change core files. -> You got that right. I am trainable... 2 minutes ago, wakabayashi said: no need for a second file. Ok great. what if someone writes a module that needs to write to my same override file. The install fails and states I have to figure out how to update my override manually? 5 minutes ago, wakabayashi said: You can even add function which aren't in the original core file. Got it. However maintaining one file when you might have either multiple modules or multiple additions to the same controller file is not very modular in design. 😎 I think though you answered my questions. Which will actually lead to more questions...
June 19, 20197 yr Yeah that's the heavy issue how have now. You try to override two times the same function. I believe that's just not possible to handle. At least I can't imagine how this could be handled. Which module is doing the override? In general you should now bring this two function overrides together into one function. Probably you need to go like this: - remove _displaySpecificPriceModificationForm from AdminProductsController.php - install the module (which will probably add this function back into the AdminProductsController.php) - Add the functionality, which you removed in step 1.
June 20, 20197 yr On 12/15/2017 at 10:52 PM, lesley said: Can you make a gist, it might do better. I have added it to git. I just added Manufacturer.
December 10, 20214 yr if someone have added this override and now update to thirtybees 1.3, please delete the override as it is now included in the core delete: override/controllers/admin/AdminProductsController.php
December 12, 20214 yr How will it be shown when there are several suppliers? Several rows or only default?
December 12, 20214 yr 1 hour ago, Briljander said: How will it be shown when there are several suppliers? Several rows or only default? default
October 2, 20233 yr This clutters up my product list too much, I have 17,700+ products and even when viewing via category it extends the list too far to the right so I can't see the "edit" buttons without collapsing the admin panel (on the left) ... very little consideration for the UI/UX when folks make things like this hardcoded in the distribution files. Just my .02 worth!
November 3, 20233 yr On 10/2/2023 at 4:37 PM, Obi said: This clutters up my product list too much, I have 17,700+ products and even when viewing via category it extends the list too far to the right so I can't see the "edit" buttons without collapsing the admin panel (on the left) ... very little consideration for the UI/UX when folks make things like this hardcoded in the distribution files. Just my .02 worth! How was the product list in PS? I guess exactly the same if I remember correctly?
November 3, 20233 yr On 10/2/2023 at 9:37 AM, Obi said: I have 17,700+ products Sounds like putting all eggs into one basket. Not the most prudent business strategy.
Create an account or sign in to comment