1

I have a dropdown menu that has categories three levels deep. At the end of each dropdown column, I have a "view all" link, which I'd like to lead users to a page similar to this page:

Categories list example

Clicking on Main Category name leads you to Category landing page with a static block, whereas the "view all" linked page should contain a list of links to all categories within the main category on the dropdown.

I've edited "app/code/local/mage/page/block/html/Topmenu.php" on line 126 to contain this anchor tag:

$html .= '<a href="' . $child->getUrl() . '" class="viewAllLink"><span>View All</span></a>';

I've been trying to make this happen for the past couple of days and I'm very stumped. I'm also wondering if this can be accomplished through phtml files. Is this possible? Can anyone please provide me with direction as how to create functionality like this?

3

A while back I worked on an extension that shows children categories when viewing a category. The code might help you to come up with the solution to your question.

You can find the extension on Github, it's a bit beta, especially on the frontend (list) part.

  • Hi, very cool extension, thanks for the answer. How could I show something similar to this; ex: Show all categories under category ID 49 on a CMS page? – joshSpiderb Dec 18 '13 at 23:53
  • On a CMS page this might be quite tricky. Better of using a normal category page and display both products AND static block so you can add content. – Sander Mangel Dec 19 '13 at 11:02
1

Here is small Suggession:

<?php
ini_set('max_execution_time', 0);
ini_set('display_errors', 1);
ini_set("memory_limit","1024M");
include('../urls.php');
include('../dbw.php');
$mageFilename = MAGE_FILE_URL_STAGING;

require_once $mageFilename;
Varien_Profiler::enable();
Mage::setIsDeveloperMode(true);


umask(0);
Mage::app('admin'); 


function get_categories(){
$i = 0; 
$category = Mage::getModel('catalog/category'); 
$tree = $category->getTreeModel(); 
$tree->load();
$ids = $tree->getCollection()->getAllIds(); 
$arr = array();
if ($ids){ 
foreach ($ids as $id){ 
$category = Mage::getModel('catalog/category'); 
$category->load($id);
$categorydata = array (
            'name' => htmlspecialchars($category->getName(),ENT_QUOTES),
            'categorydes' => htmlspecialchars($category->getDescription(),ENT_QUOTES),              
            'image' => $category->getImageUrl(),
            'metakeywords' => htmlspecialchars($category->getmeta_keywords(),ENT_QUOTES),
            'metadescrption' => htmlspecialchars($category->getmeta_description(),ENT_QUOTES),
            'magento_category_id' => $category->getId(),
            'magento_cat_spenish_id' => $category->getId(),
            'spanish_name' => htmlspecialchars($category->getName(),ENT_QUOTES),
            'parent_id' => $category->getparentId(),
            'images' => $category->getImageUrl()
                            );
echo "<pre>";
print_r($categorydata);
echo "<pre>";
$add = add_categories($categorydata);
$i = $i+1;
}
}
return $arr;

}


$arr =  get_categories();

function add_categories($parentid)
{
    // echo "INSIDE CATEGORY<br>";
    $query  = "INSERT INTO `categories` (`id`, `name`, `categorydes`, `image`, `metakeywords`, `metadescrption`, `magentoparentid`, `magento_category_id`, `magento_cat_spenish_id`, `spanish_name`, `updatedateandtime`, `status`)
VALUES (NULL,
        '$parentid[name]',
        '$parentid[categorydes]',
        '$parentid[image]',
        '$parentid[metakeywords]',
        '$parentid[metadescrption]',
        '$parentid[parent_id]',
        '$parentid[magento_category_id]',
        '$parentid[magento_category_id]',
        '$parentid[name]',
        CURRENT_TIMESTAMP,
        '1')";
    mysql_query($query)  or die(mysql_error());
    // echo $parentid['image']."<br>";
    // if($parentid['image'] != "")
    // $imagecopy = copyimgto_local($parentid['image']);

}

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.