Glasso Posted September 4, 2016 Share Posted September 4, 2016 Hi, In a multistore install of prestashop 1.6.1.6, what is the easiest way to have each shop show a message dynamically on the home page, if at least one of the products is in stock? Since our products arrive only at specific times, I am looking to have an automatic note to the customers that the shop is open to orders when I stock products. Thanks. Link to comment Share on other sites More sharing options...
rocky Posted September 5, 2016 Share Posted September 5, 2016 Try creating override/controllers/front/IndexController.php with the following: <?php class IndexController extends IndexControllerCore { public function initContent() { parent::initContent(); $result = Db::getInstance()->ExecuteS('SELECT COUNT(*) as num_products_with_stock FROM `'._DB_PREFIX_.'stock_available` WHERE `quantity` > 0 AND `id_shop` = '.(int)$this->context->shop->id); if (is_array($result) && count($result) > 0) { $this->context->smarty->assign('have_available_products', (bool)$result[0]['num_products_with_stock']); } } } Remember to go to Advanced Parameters > Performance and click the "Clear cache" button (or manually delete cache/class_index.php) so PrestaShop can find the override. You can then write a message in index.tpl like the following: {if $have_available_products}{l s='We have products in stock!'}{else}{l s='Sorry, we are out of stock. Please check back later'}{/if} 1 Link to comment Share on other sites More sharing options...
Glasso Posted September 5, 2016 Author Share Posted September 5, 2016 Thanks Rocky! I will try it and respond. 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