Advanced Search

— Forum Scope —




— Match —





— Forum Options —





Minimum search word length is 3 characters - maximum search word length is 84 characters

mail_open
Download list of Magento Categories
Alex Lockey
Member
February 25, 2014 - 9:50 am
Member Since: January 1, 2014
Forum Posts: 107
sp_UserOfflineSmall Offline

Hi,

Is there a way to download all of your Magento categories in the format in which you would upload them through Magmi?

Cheers

Avatar
Matthew Ogborne

Founder
February 25, 2014 - 12:59 pm
Member Since: July 18, 2013
Forum Posts: 4565
sp_UserOfflineSmall Offline

Hi Alex,

Kind of, I have a script that you can use for this.

I need to run for the train in a few minutes, can can you nudge me tomorrow morning and I’ll dig it out for you?

Matt

"Selling an item online is easy, but making living from a business that sells online, well that’s something different entirely!"

Ultimo Magento Theme

Alex Lockey
Member
February 25, 2014 - 1:18 pm
Member Since: January 1, 2014
Forum Posts: 107
sp_UserOfflineSmall Offline

Hi Matt,

Great thanks, speak tomorrow

Alex

Avatar
Matthew Ogborne

Founder
February 26, 2014 - 11:21 am
Member Since: July 18, 2013
Forum Posts: 4565
sp_UserOfflineSmall Offline

Hi Alex,

Download the attached file and run from the same directory where your magento installation is. This will create a file called “cats_with_ids_paths.csv” that will contain all the categories for you.

<?php

// Set errors because we need to know about them if they happen
error_reporting(E_ALL);
ini_set(‘display_errors’, ‘1’);

// Set a really high timeout & memory limit for huge catalogues
set_time_limit (600);
ini_set(‘max_execution_time’,’600′); // 10 mins timeout
ini_set(‘memory_limit’,’2048M’); // Excessive memory

// Find where we are
define(‘MAGENTO’, realpath(dirname(__FILE__)));

// Force this path manually if you have problemo’s
//define(‘MAGENTO’, ‘/var/www/your/path/to/magento‘);

// Now grab the Magento Core
require_once MAGENTO . ‘/app/Mage.php’;
Mage::app();

// Go fishing
$category = Mage::getModel ( ‘catalog/category’ );
$tree = $category->getTreeModel ();
$tree->load ();
$nodes = $tree->getNodes();

if ($nodes) {
// yay we have bites :)
$file = "cats_with_ids_paths.csv";

// Build header line
file_put_contents($file,"\"catId\",\"catName\",\"catPath\"\n");

foreach ( $nodes as $node ) {
// let em rip
$id = $node->getId();
$name = $category->load($id)->getName();

$path = ”;
$parents = $node->getPath();

foreach ($parents as $i=>$parent) {
// oo subs
$parent_id = $parent->getId();
$parent_name = $category->load($parent_id)->getName();
$path = $parent_name . ($i?’>’:”) . $path;
}

$string = ‘"’. $node->getId() . ‘","’. $name . ‘","’. $path . "\"\n";
file_put_contents($file,$string,FILE_APPEND);
//echo "$string\n";
}
} else {
echo "OoO-Err Mrs, no cateories or something went horribly wrong. Is the path correct & does the site actually have categories?";
}

"Selling an item online is easy, but making living from a business that sells online, well that’s something different entirely!"

Ultimo Magento Theme

Avatar
Matthew Ogborne

Founder
February 26, 2014 - 11:22 am
Member Since: July 18, 2013
Forum Posts: 4565
sp_UserOfflineSmall Offline

LOL, I just read my notes in that file, that kinda gives an idea of how I write code & comment it :)

Matt

"Selling an item online is easy, but making living from a business that sells online, well that’s something different entirely!"

Ultimo Magento Theme

Avatar
Dave Furness

Founder
February 26, 2014 - 11:36 am
Member Since: July 19, 2013
Forum Posts: 4606
sp_UserOfflineSmall Offline

“OoO-Err Mrs, no cateories or something went horribly wrong. Is the path correct & does the site actually have categories?”

Amazing :D

Every expert was once a beginner

Alex Lockey
Member
February 26, 2014 - 11:58 am
Member Since: January 1, 2014
Forum Posts: 107
sp_UserOfflineSmall Offline

oo subs!

Cheers Matt

Avatar
Matthew Ogborne

Founder
February 26, 2014 - 12:49 pm
Member Since: July 18, 2013
Forum Posts: 4565
sp_UserOfflineSmall Offline

Howdy Alex,

oh a quick note, this file exports the categories with the separator of “>”, so you may have to change your Magmi configuration settings for the category importing plugin to use this instead of a /.

Matt

"Selling an item online is easy, but making living from a business that sells online, well that’s something different entirely!"

Ultimo Magento Theme

Alex Lockey
Member
February 26, 2014 - 1:54 pm
Member Since: January 1, 2014
Forum Posts: 107
sp_UserOfflineSmall Offline

Hi Matt,

Will do thanks, so do I just:

– save that code as a text file
– upload to my public_html directory
– then what do you mean buy run?

Thanks

Alex

Avatar
Matthew Ogborne

Founder
February 26, 2014 - 3:40 pm
Member Since: July 18, 2013
Forum Posts: 4565
sp_UserOfflineSmall Offline

Hi Alex,

Kind of, save that file as a php file, save it to your public html folder, then navigate to it using your web browser, eg mydomain.com/filename.php

Then check the public html directory for the csv file

Note this will take a minute or two to complete

Matt

"Selling an item online is easy, but making living from a business that sells online, well that’s something different entirely!"

Ultimo Magento Theme

 

Why Should You Join UnderstandingE?

 
  • Access to over 500 step-by-step video tutorials
  • +20 video courses available
  • Magento, M2E Pro, Magmi, eBay, Amazon & Design all covered
  • Everything is in 100% Plain English
  • Learn how to build your own multi-channel software for eBay & Amazon
  • Access to the community forums, meet fellow business owners like yourself

Join Now with 2 Clicks

 

Join now for less that £1 per day you can gain access to over 400 step-by-step video tutorials & learn how to build your very own multi-channel software.

 

Forum Timezone: Europe/London

Most Users Ever Online: 1012

Currently Online:
38 Guest(s)

Currently Browsing this Page:
1 Guest(s)

Top Posters:

Jim @ Moogento: 688

Steve Froggatt: 514

Badeth - UE: 513

Jimbob: 453

Paul Cartwright: 414

Forum Stats:

Groups: 6

Forums: 37

Topics: 5221

Posts: 27485

Administrators: Matthew Ogborne: 4565, Dave Furness: 4606