getAll("SELECT u.request_path, e.type_id FROM core_url_rewrite u LEFT JOIN catalog_product_entity e ON u.product_id = e.entity_id LEFT JOIN products p ON e.sku like concat(p.sku, '%') WHERE p.id = ? AND u.category_id IS NULL AND u.is_system = 1 AND u.store_id = ?", array($m[1], $store_id)); if(count($res) > 0){ if(count($res) > 1){ foreach($res as $l){ if($l['type_id'] == 'configurable'){ header ('HTTP/1.1 301 Moved Permanently'); header ('Location: /'.$l['request_path']); exit(); } } header ('HTTP/1.1 301 Moved Permanently'); header ('Location: /'.$res[0]['request_path']); exit(); }else{ header ('HTTP/1.1 301 Moved Permanently'); header ('Location: /'.$res[0]['request_path']); exit(); } }else{ header ('HTTP/1.1 301 Moved Permanently'); header ('Location: /'); exit(); } } header ('HTTP/1.1 301 Moved Permanently'); header ('Location: /'); exit();