Created
July 24, 2015 17:48
-
-
Save rodde177/ad0500d541202bbf62c0 to your computer and use it in GitHub Desktop.
create url rewrite by sku
This file contains hidden or 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
| <?php | |
| define('MAGENTO', realpath(dirname(__FILE__))); | |
| ini_set('memory_limit', '512M'); | |
| set_time_limit (0); | |
| require_once MAGENTO . '/app/Mage.php'; | |
| Mage::app(); | |
| $products = array( | |
| "41020300"=>"product.html/ekologisk-docka-i-gots-certifierat-tyg-stoppad-med-ekologisk-ull-blavit-randig-troja-vita-skor-och-roda-byxor" | |
| ); | |
| foreach($products as $sku => $request) { | |
| $mageProduct = Mage::getModel('catalog/product')->loadByAttribute('sku',$sku); | |
| if(is_object($mageProduct)) { | |
| $target = $mageProduct->getUrlKey(); | |
| $id = $mageProduct->getId(); | |
| Mage::getModel('core/url_rewrite') | |
| ->setIsSystem(0) | |
| ->setStoreId(1) | |
| ->setOptions('RP') | |
| ->setIdPath('product/' . $id) | |
| ->setTargetPath($target . '.html') | |
| ->setRequestPath($request)->save(); | |
| } else { | |
| Mage::log('sku:' . $sku,null,'urlrewrite.log'); | |
| } | |
| } | |
| ?> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment