zimmer-media Posted December 16, 2017 Share Posted December 16, 2017 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 Link to comment Share on other sites More sharing options...
lesley Posted December 16, 2017 Share Posted December 16, 2017 Can you make a gist, it might do better. Link to comment Share on other sites More sharing options...
zimmer-media Posted December 16, 2017 Author Share Posted December 16, 2017 @lesley Sorry, there is someone on the line with me. I don't understand what you mean by that. Link to comment Share on other sites More sharing options...
zimmer-media Posted December 16, 2017 Author Share Posted December 16, 2017 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', ]; ``` Link to comment Share on other sites More sharing options...
Beeta Posted November 2, 2018 Share Posted November 2, 2018 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" Link to comment Share on other sites More sharing options...
wakabayashi Posted November 2, 2018 Share Posted November 2, 2018 Then probably your override is not set up properly. Link to comment Share on other sites More sharing options...
Beeta Posted November 5, 2018 Share Posted November 5, 2018 I cloned the original file AdminProductsController.php, modified as instructions and copied in the directory: override/controllers/admin/ Permissions are correct. Link to comment Share on other sites More sharing options...
wakabayashi Posted November 5, 2018 Share Posted November 5, 2018 Well what is your classname with extending? Have you deleted class_index.php in cache directory? Link to comment Share on other sites More sharing options...
Beeta Posted November 5, 2018 Share Posted November 5, 2018 @wakabayashi worked! (I have no cache active, didn't think to it) thank you Link to comment Share on other sites More sharing options...
Traumflug Posted November 5, 2018 Share Posted November 5, 2018 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". Link to comment Share on other sites More sharing options...
Beeta Posted November 5, 2018 Share Posted November 5, 2018 @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". Link to comment Share on other sites More sharing options...
Factor Posted June 19, 2019 Share Posted June 19, 2019 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. Link to comment Share on other sites More sharing options...
wakabayashi Posted June 19, 2019 Share Posted June 19, 2019 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. Link to comment Share on other sites More sharing options...
Factor Posted June 19, 2019 Share Posted June 19, 2019 (edited) 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, 2019 by Factor Link to comment Share on other sites More sharing options...
wakabayashi Posted June 19, 2019 Share Posted June 19, 2019 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. Link to comment Share on other sites More sharing options...
Factor Posted June 19, 2019 Share Posted June 19, 2019 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... Link to comment Share on other sites More sharing options...
wakabayashi Posted June 19, 2019 Share Posted June 19, 2019 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. Link to comment Share on other sites More sharing options...
Factor Posted June 19, 2019 Share Posted June 19, 2019 Thanks buddy. I appreciate you. Link to comment Share on other sites More sharing options...
Factor Posted June 20, 2019 Share Posted June 20, 2019 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. Link to comment Share on other sites More sharing options...
Beeta Posted December 10, 2021 Share Posted December 10, 2021 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 1 Link to comment Share on other sites More sharing options...
Briljander Posted December 12, 2021 Share Posted December 12, 2021 How will it be shown when there are several suppliers? Several rows or only default? Link to comment Share on other sites More sharing options...
datakick Posted December 12, 2021 Share Posted December 12, 2021 1 hour ago, Briljander said: How will it be shown when there are several suppliers? Several rows or only default? default 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