Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add RewriteController to allow easy handling of historic rewrites #37

Open
wants to merge 7 commits into
base: master
Choose a base branch
from
Open
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
<?php
require_once Mage::getModuleDir('controllers', 'Divante_VueStorefrontBridge') . DS . 'AbstractController.php';
class Divante_VueStorefrontBridge_RewriteController extends Divante_VueStorefrontBridge_AbstractController {

public function targetAction()
{

if (!$this->_checkHttpMethod('GET')) {
return $this->_result(500, 'Only GET method 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);

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please add a LIMIT 1 to the query to improve performance.

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I honestly thought that ->fetchOne() would do exactly like that but you get surprised by magento/Zend/Varien internals every now and then:) Limiting beforehand now introduced.

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I know, it really sucks :/
Thanks!

$result = $reader->fetchOne($select);

if ($result) {
return $this->_result(200, $result);
}
}

return $this->_result(500, 'Not possible to retrieve target location');
}

}