David Carter Posted September 11, 2020 Share Posted September 11, 2020 I need to create different product templates for specific categories for PS 1.7.6. I've tried various solutions and this one looked good, but it doesn't work. Can anyone help or suggest where I'm going wrong? Anyway, this was what I tried: 1. Create file: ProductController.php <?php class ProductController extends ProductControllerCore { private static function checkProductTemplate($link_rewrite) { return file_exists(_PS_THEME_DIR_ . 'templates/' . $link_rewrite . '.tpl'); } public function init() { parent::init(); if ($this->template == 'catalog/product.tpl') { $id_product = (int) Tools::getValue('id_product'); $tpl = 'catalog/product_' . $this->product->category; if ($this->checkProductTemplate($tpl)) { $this->setTemplate($tpl, array( 'entity' => 'product', 'id' => $id_product, )); } } } } 2. Upload to /override/controllers/front 3. create different product templates 4. add the category's SEO url to the filename, like: 147-ceramics.tpl 5. Upload to theme templates directory, next to the original product.tpl (public_html/themes/classic/templates/catalog/). This should work for both - categories and subcategories. But it doesn't work... 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