Hi, I am wondering if there is a way to get a list of all categories for ... a store? I am new to magento. I am programming a script that is to be run on the command line via a cron, and I want to sync categories from an incoming list. Therefore I want to get a list of existing categories from magento so I know whether to add one as a new category or not.
Use the API. Create a web services user with full access, generate them a key then login from your script with that user/key. The methods for pulling the category information are all documented in the API, start pulling arrays back, dump them out and then work out how your custom app is to work.
Yeah, I’ve seen that you can do something like that with a SOAP call to your web application...but why wouldn’t you be able to do that through the Mage classes? I think that’s a point of confusion for me. Is that just something overlooked in the class set? Can you even load magento data, by name for instance ( like doing an sql search) via the Mage classes?
Well, after many var_dumps and get_class_methods calls, I have come up with some non-SOAP calls to get categories. Not too efficient, but hope this helps…
catan,
thank you very much - you just saved me huge time. I have spent many hours trying to find good way of getting categories for home page content - and yours works like a charm
I’m trying to get the url path for each category also.
I tried :
$result[’url’] = $node->getCategoryUrl($result[’category_id’]);
and
$result[’url’] = $node->getUrl();
But it’s empty.
If I use :
$result[’url’] = $node->getData(’path’);
Hi
I have being through the code and this is very interesting to get the list of categories is simplifies my work . But can some body tells me where does all this code goes to get the expected result
I made this little video on how I create custom category listing blocks with Magento.
I am sure there are better ways of achieving this or even something I could have done better, but it’s just my method. I only created this it in hopes that it helps explain somethings to some people out there.