diff --git a/magento1-module/app/code/local/Divante/VueStorefrontBridge/controllers/RewriteController.php b/magento1-module/app/code/local/Divante/VueStorefrontBridge/controllers/RewriteController.php new file mode 100644 index 0000000..848242f --- /dev/null +++ b/magento1-module/app/code/local/Divante/VueStorefrontBridge/controllers/RewriteController.php @@ -0,0 +1,36 @@ +_checkHttpMethod('GET')) { + return $this->_result(405, 'Method not allowed'); + } + + $requestPath = $this->getRequest()->getParam('request_path'); + if ($requestPath) { + $reader = Mage::getSingleton('core/resource')->getConnection('core_read'); + + $select = $reader->select() + ->from('core_url_rewrite', ['target_path']) + ->where('request_path = ?', $requestPath) + ->where('store_id IN (?)', [Mage_Core_Model_App::ADMIN_STORE_ID, (int)Mage::app()->getStore()->getId()]) + ->where('category_id is null') + ->where('product_id is null') + ->order('store_id DESC') + ->limit(1); + + $result = $reader->fetchOne($select); + + if ($result) { + return $this->_result(200, $result); + } + + return $this->_result(404, 'No matching request path found'); + } + + return $this->_result(400, 'Malforemd request'); + + } +}