Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6038617
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 23, 20262026-05-23T06:14:53+00:00 2026-05-23T06:14:53+00:00

I have use following code to display category and there product on click patent

  • 0

I have use following code to display category and there product on click patent category :

<?php 
$obj = new Mage_Catalog_Block_Navigation();
$cat = Mage::getModel('catalog/category')->load($obj->getCurrentCategory()->getId()); //get current cat

$subcats = $cat->getChildren(); // Get sub cats
// loop on it


<div class="page-title">
<h1><?php echo $cat['name'];?></h1>
</div>
<div id="accordion2">

 <dl class="accordion2" id="slider2">

<?php
function sortCategories($a, $b) {
return strcmp($a['name'], $b['name']);
}
?>
<?php

$categoryArray = array();
foreach(explode(',',$subcats) as $subCatid){ // split up the mage data for use
$_category = Mage::getModel('catalog/category')->load($subCatid);
if($_category->getIsActive()){
$id = $_category->getId();
$caturl  = $_category->getURL(); // get link to image
$catname = $_category->getName(); // get the name
$catdesc = $_category->getDescription(); // get the name
if($_category->getImageUrl()){
$catimg = $_category->getImageUrl(); // hey, we got image
}else{
$catimg=null;
continue;
} // this is the basic testing data, format as desired & good luck!
$catdescTwo = substr(strip_tags($catdesc), 0, 70);
$categoryArray[] = array(
'id' => $id,
'name' => $catname,
'url' => $caturl,
'desc' => $catdescTwo,
'img' => $catimg
);
}
}
usort($categoryArray, "sortCategories");
//echo  $subcats = $cat->getChildren();
$i=0;
foreach ($categoryArray as $categoryItem) {
    $i++;
//print_r($categoryItem);
$catid=$categoryItem['id'];
$catid=$catid;
echo '<dt><h2 class="productbg_'.$i.'">'.$categoryItem['name'].'<span></span></h2></dt>
<dd>';

$category = new Mage_Catalog_Model_Category();
$category->load($catid); //My cat id is 10


$prodCollection = $category->getProductCollection();

foreach ($prodCollection as $product) {
 $productid = $product->getId();
$model = Mage::getModel('catalog/product');
$product = $model->load($productid);
//echo $name = $product->getName(); ///Store all th eproduct id in $prdIds array
//echo $product->getImageUrl();

  $available = $product->getResource()->getAttribute('available')->getFrontend()->getValue($product); 
?>
<ol class="products-list" id="products-list">
<li class="item<?php if( ++$_iterator == sizeof($productCollection) ): ?> last<?php endif; ?>">

            <?php // Product Image ?>

                <?php 

$strImagePath = '';

$wtImageSize = '';

$wtProdouct = Mage::getModel('catalog/product')->load($product->getId()); 

$wtProductImages = $wtProdouct->getMediaGalleryImages(); 



// Loop through all of the images of the current product.

foreach($wtProductImages as $wtImage) {



// If we found one with the label of 'popup', thats the one we want.

if($wtImage->getLabel() == 'popup') {



// Get the image and resize it.

$strImagePath = '/media/catalog/product' . $wtImage->getFile(); 

$wtImageSize = getimagesize($_SERVER['DOCUMENT_ROOT'] . $strImagePath);

}} ?>

            <a href="<?php echo $product->getProductUrl() ?>"  class="product-image"><img id="wt-popup-<?php echo $product->getId() ?>" src="<?php echo $this->helper('catalog/image')->init($product, 'small_image')->resize(113); ?>"  alt="<?php echo $this->stripTags($this->getImageLabel($product, 'small_image'), null, true) ?>"  /></a>

                <?php if(!empty($strImagePath)) { ?>

<script defer="defer" type="text/javascript">WT.showPreview("<?php echo $this->htmlEscape($product->getName()) ?>"

, "<?php echo($strImagePath); ?>", "wt-popup-<?php echo $product->getId() ?>", <?php echo $wtImageSize[0] ?>, 

<?php echo $wtImageSize[1] ?>);</script><?php } ?>

            <?php // Product description ?>

            <div class="product-shop">

                <div class="f-fix">

                    <h2 class="product-name"><a href="<?php echo $product->getProductUrl() ?>"><?php echo $name = $product->getName();?> <span> <?php  if(isset($available) && $available!=""){?>- AVAILABLE IN <?php echo $available?><?php } ?></span> </a> </h2>

                    <?php if($product->getRatingSummary()): ?>

                    <?php echo $this->getReviewsSummaryHtml($product) ?>

                    <?php endif; ?>

                    <?php echo $this->getPriceHtml($product, true) ?>

                    <?php if($product->isSaleable()): ?>


                    <?php else: ?>

                        <p class="availability out-of-stock"><span><?php echo $this->__('Out of stock') ?></span></p>

                    <?php endif; ?>

                    <div class="desc std">

                        <?php echo $product->getShortDescription(); ?>

                        <a href="<?php echo $product->getProductUrl() ?>" title="<?php echo $this->stripTags($product->getName(), null, true) ?>" class="link-more"><?php echo $this->__('Learn More') ?></a>

                    </div>

                    <ul class="add-to-links">

                        <?php if ($this->helper('wishlist')->isAllow()) : ?>

                        <?php endif; ?>

                        <?php if($_compareUrl=$this->getAddToCompareUrl($product)): ?>

                            <li><span class="separator">|</span> <a href="<?php echo $_compareUrl ?>" class="link-compare"><?php echo $this->__('Add to Compare') ?></a></li>

                        <?php endif; ?>

                    </ul>

                </div>

            </div>

        </li>

</ol>
<?php }?>


<?php  }
?>


</dl>
</div>

<script type="text/javascript">
var slider2=new accordion.slider("slider2");
slider2.init("slider2","open");
</script>

but when click on image of product , url of product like :http://purelygourmets.com/test/index.php/catalog/product/view/id/189/s/ormeaux-et-tacaud-120-g/category/4/

I want Correct url like :http://purelygourmets.com/test/index.php/caviar/caviar-accessories/ormeaux-et-tacaud-120-g.html

site url :http://purelygourmets.com/test/index.php/

Thanks

  • 1 1 Answer
  • 2 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-23T06:14:54+00:00Added an answer on May 23, 2026 at 6:14 am

    I’m still learning Magento myself, but have you tried $product->getUrlPath();?

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have the following code that I use to display detail rows in a
I have an array of objects, and i use following code to get in
I have the following code: use Imager::Screenshot 'screenshot'; my $img = screenshot(hwnd => 'active',
I have the following code: use strict; function isDefined(variable) { return (typeof (window[variable]) ===
I have tried to use the following snippet of code: int main() { string
I have following code snippet that i use to compile class at the run
I have the following code I use to insert form data into a single
I have the following code which I use to match fancybox possible elements: $('a.grouped_elements').each(function(){
I have the following code #!/usr/bin/perl use Tie::File; tie my @last_id, 'Tie::File', 'last_id.txt' or
I have the following code that works without using throw however when I use

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.