Vinai / groupscatalog2

Magento extension to enable you to hide categories and products from customers depending on their customer group. This is a Magento 1.6 and newer compatible version of the Netzarbeiter Customer Groups Catalog extension.
139 stars 60 forks source link

Are publicly invisible pages excluded from the sitemap.xml? #94

Closed kalenjordan closed 10 years ago

kalenjordan commented 10 years ago

I have a page that's only visible to a certain logged-in customer group. Should that page be excluded from sitemap.xml? Currently it isn't.

I did a brief search of current issues here in github and didn't notice anything related to this. Hope I'm not missing something obvious!

Thanks!

Vinai commented 10 years ago

No, you are right. Currently the visibility settings are not applied to the sitemap generation. The module is completely limited to the frontend scope, but even if not, the sitemap entity loading bypasses the regular entity load events. For that reason it looks like it requires another two rewrites. First one for Mage_Sitemap_Model_Resource_Catalog_Product, second one for Mage_Sitemap_Model_Resource_Catalog_Category. In both cases the inner join on the groupscatalog table needs to be added to the select being built and executed in the getCollection() methods.

kalenjordan commented 10 years ago

Awesome thanks for the quick reply, Vinai! I may try and attack this myself when I get a bit of time.

Vinai commented 10 years ago

Sorry I don't have time to do and test it myself right now. If you want, use Netzarbeiter_GroupsCatalog2_Model_Resource_Filter::_addGroupsCatalogFilterToSelect() as a reference for the join.

kalenjordan commented 10 years ago

No worries! Okay thanks! I'll keep you posted!

Vinai commented 10 years ago

Hi Kalen, it would be great if you could test the latest commit f225c39. The intention of the commit is to only allow entities visible to the NOT LOGGED IN group to be displayed to be included in the sitemap.

kalenjordan commented 10 years ago

Sweet thanks Vinai! You got to it before I did - shocker! :)

I'll try and test this today!

kalenjordan commented 10 years ago

@Vinai I did a quick test locally and it didn't seem to work :(

I looked through the code briefly - I haven't really wrapped my head around it thoroughly but it seems like the Netzarbeiter_GroupsCatalog2_Model_Sitemap_Resource_Catalog_Category::_loadEntities() method which adds the filter to the sitemap resource isn't being called...

Vinai commented 10 years ago

I've left an inline reply in the commit to your comment there, too. But this thread is a better place for the issue discussion. Which version of Magento are you using?

kalenjordan commented 10 years ago

EE 1.12.0.2

Vinai commented 10 years ago

Refactored the code a bit and added (untested) support for versions < 1.13 EE and 1.8 CE in commits c4289caa33e0d1c0c59b43016de92967ca227ee2 and 778148f. Please let me know if that works for you.

kalenjordan commented 10 years ago

Thanks! :)

So there were two places that the resource model wasn't being found, so changing them from a getResourceModel to a getModel fixed it - I wasn't sure if that was just a typo or something...?

https://github.com/Vinai/groupscatalog2/blob/master/app/code/community/Netzarbeiter/GroupsCatalog2/Model/Sitemap/Resource/Catalog/Category.php#L37 https://github.com/Vinai/groupscatalog2/blob/master/app/code/community/Netzarbeiter/GroupsCatalog2/Model/Sitemap/Resource/Catalog/Product.php#L37

After making those changes locally, it worked.

Vinai commented 10 years ago

Great, commited. Closing issue :)