Magento – How to import Enterprise URL Rewrites in 1.13

ee-1.13enterprise-1.13magento-enterpriseurl-rewrite

We recently migrated from a proprietary shopping cart to Magento Enterprise.

Currently we are using a custom module to redirect the old product URL's to the new Magento product URL's.

However, I am looking to move on from this front-end controller that handles this logic, to importing them as URL rewrite rules.

There seems to be a lot of documentation for creating a URL rewrite url in community edition, which uses the deprecated core_url_rewrite table.

Previously, you would do something like:

$results = Mage::getModel('core/url_rewrite')
    ->setIsSystem(0)
    ->setOptions('RP')
    ->setIdPath($legacy_url)
    ->setRequestPath($legacy_url)
    ->setTargetPath($url)
    ->setDescription('legacy product id '.$legacy_id)
    ->save();

However, in Enterprise 1.13, the model I think I should be using is: enterprise_urlrewrite/url_rewrite

Can someone advise on how to do the equivalent? I can't seem to get it to show up in the admin, even after doing a reindex.

Thanks

Best Answer

Firsly the model is now Enterprise_UrlRewrite_Model_Url_Rewrite:

Mage::getModel('enterprise_urlrewrite/url_rewrite');

Secondly the options have changed slightly to.

Options

store_id,
identifier
target_path
options
description,
category_id
product_id

Note: category and product id are optional only for category and product rewrites

So assuming that your code is not for product or category rewrites:

$results = Mage::getModel('enterprise_urlrewrite/url_rewrite')
    ->setStoreId($store_id)
    ->setOptions('RP')
    ->setIdentifier($legacy_url)
    ->setTargetPath($url)
    ->setDescription('legacy product id '.$legacy_id)
    ->save();
Related Topic