Mage::getModel('catalog/category')->load($id) is not working (no data is loaded, and getId() is empty).
but if I do this:
$collection = Mage::getModel('catalog/category')->getCollection();
foreach($collection as $category) {
if($category->getId() == $id) {
echo "it has been founnnd!!!";
}
}
it works?
I should mention I am running this code through cli with phpunit tests so its bootstrapped. My guess is that there might be an issue with scope?
I think the issue must be with your unit tests or somewhere else.
Mage::getModel('catalog/category')
->setStoreId($store_id)
->load($id);
works perfectly fine for me, no matter whether I use PHP's apache
, apache2handler
, cgi
, cgi-fcgi
or cli
SAPI and no matter which Magento version (CE 1.3, 1.5, 1.6 and EE 1.11) I've tried.
What I noticed (yes, after 3 years) is that:
1) Category will not load if you have category flat tables enabled and indexes are not up to date
2) Category will not load if it's not into "Default Category"
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With