Redirects in Magento have me utterly confused. Enterprise 1.13 has not helped the situation. My problem is this, I want to add a product link widget to the home page but newer products do not show up. I've traced the problem back to Mage_Catalog_Block_Widget_Link::getHref()
:
$urlRewriteResource = Mage::getResourceSingleton('core/url_rewrite');
$href = $urlRewriteResource->getRequestPathByIdPath($this->getData('id_path'), $store);
Now, the Mage_Core_Model_Url_Rewrite
model uses the table core_url_rewrite
. And my new products do not exist in that table! Weird, because they are Enabled, visible in Catalog, they have a url_key and I can navigate to the product page just fine. So they must exist in one of the other Enterprise tables. Which one?
core_url_rewrite -> Url Rewrites
enterprise_catalog_category_rewrite -> Relation between rewrites and categories
enterprise_catalog_product_rewrite -> Relation between rewrites and products
enterprise_url_rewrite -> URL Rewrite
enterprise_url_rewrite_redirect -> Permanent redirect
enterprise_url_rewrite_redirect_rewrite -> Relation between rewrites and redirects
Yep, it exists in the enterprise_url_rewrite
table ...
+----------------+-----------------------+--------------------------------+-----------+------+-----------------------+-----+----------+----------+-------------+
| url_rewrite_id | request_path | target_path | is_system | guid | identifier | inc | value_id | store_id | entity_type |
+----------------+-----------------------+--------------------------------+-----------+------+-----------------------+-----+----------+----------+-------------+
| 31282261 | product-1-working | catalog/product/view/id/256037 | 1 | xyz | product-1-working | 1 | 9236282 | 0 | 3 |
| 31294573 | product-2-not-working | catalog/product/view/id/268697 | 1 | xyz | product-2-not-working | 1 | 9610723 | 0 | 3 |
+----------------+-----------------------+--------------------------------+-----------+------+-----------------------+-----+----------+----------+-------------+
2 rows in set (0.00 sec)
but not in the core_url_rewrite
table ...
+----------------+----------+-------------+------------+----------------+-----------------------+--------------------------------+-----------+---------+-------------+
| url_rewrite_id | store_id | category_id | product_id | id_path | request_path | target_path | is_system | options | description |
+----------------+----------+-------------+------------+----------------+-----------------------+--------------------------------+-----------+---------+-------------+
| 3512685 | 1 | NULL | 256037 | product/256037 | product-1-working.htm | catalog/product/view/id/256037 | 1 | NULL | NULL |
+----------------+----------+-------------+------------+----------------+-----------------------+--------------------------------+-----------+---------+-------------+
1 row in set (0.34 sec)
Next I tried reindexing the url indexes (and if someone could explain the difference between these I'd appreciate it)
$ php shell/indexer.php --reindex catalog_url_product,url_redirect
Product URL Rewrites index was rebuilt successfully
URL Redirects index was rebuilt successfully
Nope, still nothing. What do I have to do to get products in the core_url_rewrite
table, other than by creating them manually myself?
$urlRewriteResource = Mage::getResourceSingleton('core/url_rewrite');
to$urlRewriteResource = Mage::getResourceSingleton('enterprise/url_rewrite');
does it work then? It may just be an oversight inMage_Catalog_Block_Widget_Link
.