-
Notifications
You must be signed in to change notification settings - Fork 49
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
nhp
wants to merge
7
commits into
DivanteLtd:master
Choose a base branch
from
gastrohero:feature/add-rewrite-controler
base: master
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from 6 commits
Commits
Show all changes
7 commits
Select commit
Hold shift + click to select a range
d6adc55
Add RewriteController to allow easy handling of historic rewrites
nhp 50c5af8
Add LIMIT clause to normalize performance for big redirect databases
nhp 3e3b407
Added store_id as parameter
nhp 1f2e9d2
Improve status code handling
nhp 539a486
Update RewriteController.php
ResuBaka 92e6e46
Update RewriteController.php
ResuBaka 2acfdfd
Check that rewrite is not internal product or category rewrite
ResuBaka File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
34 changes: 34 additions & 0 deletions
34
magento1-module/app/code/local/Divante/VueStorefrontBridge/controllers/RewriteController.php
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
<?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(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()]) | ||
->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'); | ||
|
||
} | ||
} |
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I personally avoid using the globally set store id, had some issues in the past with having the wrong store.
might we require it to be set in the URL as param?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Here i think we should have both, the
Mage::app()->getStore()->getId()
as a fallback when no storeId is set in the request?Like for example:
What do you think about that? @sandermangel