Skip to main content

I'm doing it in phtml file like this way

<?php $categories = Mage::getModel('catalog/category')->getCollection()->addAttributeToSelect('*'); ?>

<?php foreach ($categories as $category): ?>
   <?php $categorySku = $category->getCategory_sku(); ?>
   <?php print_r ($categorySku); ?>
<?php endforeach; ?>

That way I can populate all my custom category attribute values which is category_sku :).

And this will make it to a select option list.

    <?php $categories = Mage::getModel('catalog/category')->getCollection()->addAttributeToSelect('*'); ?>
    
        <select id="my-id" name="my-name">
            <option value="">Select</option>
            <?php foreach ($categories as $category): ?>
<?php /*magento fetch data by using get and attibute name like banner_id change to getBannerId*/   ?>
                <?php $categorySku = $category->getCategory_sku>getCategorySku(); ?>
                <option value="<?php echo $categorySku; ?>"><?php echo $categorySku; ?></option>
            <?php endforeach; ?>
        </select>

I'm doing it in phtml file like this way

<?php $categories = Mage::getModel('catalog/category')->getCollection()->addAttributeToSelect('*'); ?>

<?php foreach ($categories as $category): ?>
   <?php $categorySku = $category->getCategory_sku(); ?>
   <?php print_r ($categorySku); ?>
<?php endforeach; ?>

That way I can populate all my custom category attribute values which is category_sku :).

And this will make it to a select option list.

<?php $categories = Mage::getModel('catalog/category')->getCollection()->addAttributeToSelect('*'); ?>

    <select id="my-id" name="my-name">
        <option value="">Select</option>
        <?php foreach ($categories as $category): ?>
            <?php $categorySku = $category->getCategory_sku(); ?>
            <option value="<?php echo $categorySku; ?>"><?php echo $categorySku; ?></option>
        <?php endforeach; ?>
    </select>

I'm doing it in phtml file like this way

<?php $categories = Mage::getModel('catalog/category')->getCollection()->addAttributeToSelect('*'); ?>

<?php foreach ($categories as $category): ?>
   <?php $categorySku = $category->getCategory_sku(); ?>
   <?php print_r ($categorySku); ?>
<?php endforeach; ?>

That way I can populate all my custom category attribute values which is category_sku :).

And this will make it to a select option list.

    <?php $categories = Mage::getModel('catalog/category')->getCollection()->addAttributeToSelect('*'); ?>
    
        <select id="my-id" name="my-name">
            <option value="">Select</option>
            <?php foreach ($categories as $category): ?>
<?php /*magento fetch data by using get and attibute name like banner_id change to getBannerId*/   ?>
                <?php $categorySku = $category->getCategorySku(); ?>
                <option value="<?php echo $categorySku; ?>"><?php echo $categorySku; ?></option>
            <?php endforeach; ?>
        </select>
Source Link
Wakanina
  • 764
  • 2
  • 13
  • 25

I'm doing it in phtml file like this way

<?php $categories = Mage::getModel('catalog/category')->getCollection()->addAttributeToSelect('*'); ?>

<?php foreach ($categories as $category): ?>
   <?php $categorySku = $category->getCategory_sku(); ?>
   <?php print_r ($categorySku); ?>
<?php endforeach; ?>

That way I can populate all my custom category attribute values which is category_sku :).

And this will make it to a select option list.

<?php $categories = Mage::getModel('catalog/category')->getCollection()->addAttributeToSelect('*'); ?>

    <select id="my-id" name="my-name">
        <option value="">Select</option>
        <?php foreach ($categories as $category): ?>
            <?php $categorySku = $category->getCategory_sku(); ?>
            <option value="<?php echo $categorySku; ?>"><?php echo $categorySku; ?></option>
        <?php endforeach; ?>
    </select>