sitemap.xml - category page last update

56 views
Skip to first unread message

Ifrim Daniel

unread,
Sep 5, 2013, 8:23:14 AM9/5/13
to msem...@googlegroups.com
I see in your documentation that you recommend to change the last updated date for a category page in sitemap.xml.
http://www.semantium.de/msemantic/readme.html
$xml = sprintf('%s%s%s%.1f',
        htmlspecialchars($baseUrl . $item->getUrl()),
        substr(Mage::getModel('catalog/category')->load($item->getId())->getUpdatedAt(),0,10),
        $changefreq,
        $priority
      );
$io->streamWrite($xml);

My question: Is this is a good idea indeed?
A category page contains links to products from that category. Aren't the products inside the category more important ? The category's data won't be modified in most cases for a very long time.
$category->getUpdatedAt() will return the last date when a category was saved (Admin > Catalog > Manage Category > a category + Save button or other way).
The updated_at date in catalog_category_entity only reflects the category's data itself. The updated_at date is not changed when the category has a new product or a products goes out of stock (no more in the category page).
Wouldn't be better not to change the last update date in sitemap.xml for a category ?
The better way would be to have an alternate 'updated date' when a product is added in a category or goes out of stock/disabled/deleted. In Sitemap.php there would be a correct date. Still I'm not looking forward to code such a new 'updated date' field.

I've made a simple test. Added a product to a category and saw in the database that updated_at for a category wasn't changed.
Some categories in the store have updated_at set to a previous date (months ago). I'm not sure if I should use your example to change the categories dates in Sitemap.php.

For products is ok to have the date of the latest write for a product. Stock changes, price changes and other data will be reflected correctly in updated_at for a product (catalog_product_entity table).


I have a suggestion for your example on how to change the date for products in Sitemap.php.
Instead of loading all product (100+ queries) to get the field updated_at; this code would be better:
...
$updated_at = Mage::getResourceModel('catalog/product')->getAttributeRawValue($item->getId(), 'updated_at', $storeId);
...
http://stackoverflow.com/questions/6924226/magento-product-attribute-get-value


Looking forward to clarify the updated_at date for categories in Sitemap.php.
Best regards,
Daniel
Reply all
Reply to author
Forward
0 new messages