zimmer-media Posted December 16, 2017 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
zimmer-media Posted December 16, 2017 Author Posted December 16, 2017 @lesley Sorry, there is someone on the line with me. I don't understand what you mean by that.
zimmer-media Posted December 16, 2017 Author 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', ]; ```
Beeta Posted November 2, 2018 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"
wakabayashi Posted November 2, 2018 Posted November 2, 2018 Then probably your override is not set up properly.
Beeta Posted November 5, 2018 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.
wakabayashi Posted November 5, 2018 Posted November 5, 2018 Well what is your classname with extending? Have you deleted class_index.php in cache directory?
Beeta Posted November 5, 2018 Posted November 5, 2018 @wakabayashi worked! (I have no cache active, didn't think to it) thank you
Traumflug Posted November 5, 2018 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".
Beeta Posted November 5, 2018 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".
Factor Posted June 19, 2019 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.
wakabayashi Posted June 19, 2019 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.
Factor Posted June 19, 2019 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
wakabayashi Posted June 19, 2019 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.
Factor Posted June 19, 2019 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...
wakabayashi Posted June 19, 2019 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.
Factor Posted June 20, 2019 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.
Beeta Posted December 10, 2021 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
Briljander Posted December 12, 2021 Posted December 12, 2021 How will it be shown when there are several suppliers? Several rows or only default?
datakick Posted December 12, 2021 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
Obi Posted October 2, 2023 Posted October 2, 2023 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!
the.rampage.rado Posted November 3, 2023 Posted November 3, 2023 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?
nickz Posted November 3, 2023 Posted November 3, 2023 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.
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