Can I initialize some variable in product controller product.php, then load it to header controller header.php and use it in view header.twig, to load certain information based on this variable? If not, how can I determine whether the page with the product is open or not?
            Asked
            
        
        
            Active
            
        
            Viewed 276 times
        
    3
            
            
        
        focus.style
        
- 6,612
 - 4
 - 26
 - 38
 
        boguchar
        
- 89
 - 10
 
1 Answers
2
            Easiest way determine product page in header.php
if (isset($this->request->get['product_id'])) {
    $product_id = (int)$this->request->get['product_id'];
} else {
    $product_id = 0;
}
if ($product_id) {
//... some code for product page
}
Also you can combine check with product controller route in header.php
if (isset($this->request->get['route']) && $this->request->get['route'] == 'product/product' && isset($this->request->get['product_id'])) {
// some code for product page
}
        OcPh
        
- 71
 - 3