3
votes

Mage::app()->getStore()->getWebsiteId(); does not work in some blocks, (called from an instatianted Model).

If I remember correctly, it works in the cart block, but does not work in the cart Items block.

I thought it was an intersting problem. I also noticed that Mage::getModel('customer/session')->getCustomer()->getGroupId();

also doesnt work in the same situation.

It works from within a template in a block called: Mage_Checkout_Block_Cart

But it doesnt work from within a block called: OrganicInternet_SimpleConfigurableProducts_Checkout_Block_Cart_Item_Renderer which extends Mage_Checkout_Block_Cart_Item_Renderer

Any thoughts?

1

1 Answers

1
votes

What version of magento is this?

Ive never seen the particular method you are calling to get the website id. Ive only ever used Mage::app()->getStore()->getWebsite()->getId();

If getWebsiteId works then I would imagine it is data set to the store data array and not actually a method. Data like that can be variable and I can't tell you off the top of my head where or when that would be set.

As far as getting the group id of the customer in the customer session, if you call the customer session with getModel() you will get a new session instead of the "singleton" session that magento is going to actually store the session data in. You need to call all session objects with Mage::getSingleton('customer/session').

You will only have a customer in the session if a customer is logged in.