News:

Support the VirtueMart project and become a member

Main Menu

404 The requested product does not exist.

Started by jaderotheram, February 05, 2013, 10:46:14 AM

Previous topic - Next topic

jaderotheram

So I was using a solution posted on here in order to hide "add to cart" from certain products using Custom Fields and altering Product Details.

I updated replaced the file...

templates/my_template/html/com_virtuemart/productdetails/default.php

Now everytime I click on a Category either from a Virtuemart Category List or from the Main Navigation which links to Virtuemart Categories I get "404 The requested product does not exist" on the page (see screenshot)

However, on the front page, I still see featured products and when I click on them it works fine.

Site is due to go live this week so any help would be greatly appreciated.

<?php
/**
 *
 * Show the product details page
 *
 * @package VirtueMart
 * @subpackage
 * @author Max Milbers, Eugen Stranz
 * @author RolandD,
 * @todo handle child products
 * @link http://www.virtuemart.net
 * @copyright Copyright (c) 2004 - 2010 VirtueMart Team. All rights reserved.
 * @license http://www.gnu.org/copyleft/gpl.html GNU/GPL, see LICENSE.php
 * VirtueMart is free software. This version may have been modified pursuant
 * to the GNU General Public License, and as distributed it includes or
 * is derivative of works licensed under the GNU General Public License or
 * other free or open source software licenses.
 * @version $Id: default.php 5444 2012-02-15 15:31:35Z Milbo $
 */
// Check to ensure this file is included in Joomla!
defined('_JEXEC') or die('Restricted access');

// addon for joomla modal Box
JHTML::_('behavior.modal');
JHTML::_('behavior.tooltip');
$url JRoute::_('index.php?option=com_virtuemart&view=productdetails&task=askquestion&virtuemart_product_id=' $this->product->virtuemart_product_id '&virtuemart_category_id=' $this->product->virtuemart_category_id '&tmpl=component');
$document = &JFactory::getDocument();
$document->addScriptDeclaration("
jQuery(document).ready(function($) {
$('a.ask-a-question').click( function(){
$.facebox({
iframe: '" 
$url "',
rev: 'iframe|550|550'
});
return false ;
});
/* $('.additional-images a').mouseover(function() {
var himg = this.href ;
var extension=himg.substring(himg.lastIndexOf('.')+1);
if (extension =='png' || extension =='jpg' || extension =='gif') {
$('.main-image img').attr('src',himg );
}
console.log(extension)
});*/
});
"
);
/* Let's see if we found the product */
if (empty($this->product)) {
    echo 
JText::_('COM_VIRTUEMART_PRODUCT_NOT_FOUND');
    echo 
'<br /><br />  ' $this->continue_link_html;
    return;
}
?>


<div class="productdetails-view">

    <?php
    
// Product Navigation
    
if (VmConfig::get('product_navigation'1)) { ?>

<div class="product-neighbours">
    <?php
    if (!empty(
$this->product->neighbours ['previous'][0])) {
$prev_link JRoute::_('index.php?option=com_virtuemart&view=productdetails&virtuemart_product_id=' $this->product->neighbours ['previous'][0] ['virtuemart_product_id'] . '&virtuemart_category_id=' $this->product->virtuemart_category_id);
echo JHTML::_('link'$prev_link$this->product->neighbours ['previous'][0]
['product_name'], array('class' => 'previous-page'));
    }
    if (!empty($this->product->neighbours ['next'][0])) {
$next_link JRoute::_('index.php?option=com_virtuemart&view=productdetails&virtuemart_product_id=' $this->product->neighbours ['next'][0] ['virtuemart_product_id'] . '&virtuemart_category_id=' $this->product->virtuemart_category_id);
echo JHTML::_('link'$next_link$this->product->neighbours ['next'][0] ['product_name'], array('class' => 'next-page'));
    }
    ?>

    <div class="clear"></div>
        </div>
    <?php // Product Navigation END
    
?>


    <?php
    
// Product Edit Link
    
echo $this->edit_link;
    
// Product Edit Link END
    
?>


 
    <div>
<div class="width40 floatleft">
<?php
echo $this->loadTemplate('images');
?>

</div>

<div class="width60 floatright">
    <div class="spacer-buy-area">
  <?php // Product Title  ?>
    <h1><?php echo $this->product->product_name ?></h1>
    <?php // Product Title END  ?>
      <?php // PDF - Print - Email Icon
    
if (VmConfig::get('show_emailfriend') || VmConfig::get('show_printicon') || VmConfig::get('pdf_button_enable')) { ?>

<div class="icons">
    <?php
    
//$link = (JVM_VERSION===1) ? 'index2.php' : 'index.php';
    $link 'index.php?tmpl=component&option=com_virtuemart&view=productdetails&virtuemart_product_id=' $this->product->virtuemart_product_id;
    $MailLink 'index.php?option=com_virtuemart&view=productdetails&task=recommend&virtuemart_product_id=' $this->product->virtuemart_product_id '&virtuemart_category_id=' $this->product->virtuemart_category_id '&tmpl=component';

    if (VmConfig::get('pdf_icon'1) == '1') {
echo $this->linkIcon($link '&format=pdf''COM_VIRTUEMART_PDF''pdf_button''pdf_button_enable'false);
    }
    echo $this->linkIcon($link '&print=1''COM_VIRTUEMART_PRINT''printButton''show_printicon');
    echo $this->linkIcon($MailLink'COM_VIRTUEMART_EMAIL''emailButton''show_emailfriend');
    ?>

    <div class="clear"></div>
        </div>
<?php

// PDF - Print - Email Icon END  ?>


<?php // TO DO in Multi-Vendor not needed at the moment and just would lead to confusion
/* $link = JRoute::_('index2.php?option=com_virtuemart&view=virtuemart&task=vendorinfo&virtuemart_vendor_id='.$this->product->virtuemart_vendor_id);
  $text = JText::_('COM_VIRTUEMART_VENDOR_FORM_INFO_LBL');
  echo '<span class="bold">'. JText::_('COM_VIRTUEMART_PRODUCT_DETAILS_VENDOR_LBL'). '</span>'; ?>
<a class="modal" href="<?php echo $link ?>"><?php echo $text ?></a><br />
*/ ?>

<?php
if ($this->showRating) {
    $maxrating VmConfig::get('vm_maximum_rating_scale',5);

if (empty($this->rating)) { ?>

<span class="vote"><?php echo JText::_('COM_VIRTUEMART_RATING').' '.JText::_('COM_VIRTUEMART_UNRATED'?></span>
<?php } else {
$ratingwidth = ( $this->rating->rating 100 ) / $maxrating;//I don't use round as percetntage with works perfect, as for me
?>

<span class="vote">
<?php echo JText::_('COM_VIRTUEMART_RATING').' '.round($this->rating->rating2) . '/'$maxrating?><br/>
<span title=" <?php echo (JText::_("COM_VIRTUEMART_RATING_TITLE") . $this->rating->rating '/' $maxrating?>" class="vmicon ratingbox" style="display:inline-block;">
<span class="stars-orange" style="width:<?php echo $ratingwidth;?>%">
</span>
</span>
</span>
<?php
}
}

// Product Price
if ($this->show_prices and (empty($this->product->images[0]) or $this->product->images[0]->file_is_downloadable == 0)) {
    echo $this->loadTemplate('showprices');
}
?>


<?php
// Add To Cart Button
//  if (!empty($this->product->prices) and !empty($this->product->images[0]) and $this->product->images[0]->file_is_downloadable==0 ) {
if (!VmConfig::get('use_as_catalog'0) and !empty($this->product->prices)) {
    echo $this->loadTemplate('addtocart');
}  // Add To Cart Button END
?>


<?php
// Availability Image
/* TO DO add width and height to the image */
if (!empty($this->product->product_availability)) {
   $stockhandle VmConfig::get('stockhandle''none');
if (
$stockhandle == 'risetime' and ($this->product->product_in_stock $this->product->product_ordered) < 1) {
    
?>
<div class="availability">
    <?php echo JHTML::image(JURI::root() . VmConfig::get('assets_general_path') . 'images/availability/' VmConfig::get('rised_availability''7d.gif'), VmConfig::get('rised_availability''7d.gif'), array('class' => 'availability')); ?>
    </div>
<?php } else {
    
?>

    <div class="availability">
<?php echo JHTML::image(JURI::root() . VmConfig::get('assets_general_path') . 'images/availability/' $this->product->product_availability$this->product->product_availability, array('class' => 'availability')); ?>
    </div>
<?php
}
}
?>

       
        <?php
// Ask a question about this product
if (VmConfig::get('ask_question'1) == '1') { ?>

   <div class="ask-a-question">
<a class="ask-a-question" href="<?php echo $url ?>" ><?php echo JText::_('COM_VIRTUEMART_PRODUCT_ENQUIRY_LBL'?></a>
<!--<a class="ask-a-question modal" rel="{handler: 'iframe', size: {x: 700, y: 550}}" href="<?php echo $url ?>"><?php echo JText::_('COM_VIRTUEMART_PRODUCT_ENQUIRY_LBL'?></a>-->
</div>
<?php }
?>


           <?php if (!empty($this->product->customfieldsSorted['ontop'])) {
$this->position='ontop';
echo $this->loadTemplate('customfields');
    } 
// Product Custom ontop end
    
?>

<?php
// Manufacturer of the Product
if (VmConfig::get('show_manufacturers'1) && !empty($this->product->virtuemart_manufacturer_id)) {
    $this->loadTemplate('manufacturer');
}
?>


    </div>
</div>
<div class="clear"></div>
    </div>

<?php // Product Description
if (!empty($this->product->product_desc)) { ?>

        <div class="product-description">
<?php /** @todo Test if content plugins modify the product description */ ?>
    <span class="title"><?php echo JText::_('COM_VIRTUEMART_PRODUCT_DESC_TITLE'?></span>
<?php echo $this->product->product_desc?>
        </div>
    <?php
    
// Product Description END

    
if (!empty($this->product->customfieldsSorted['normal'])) {
$this->position='normal';
echo $this->loadTemplate('customfields');
    } 
// Product custom_fields END
    // Product Packaging
    
$product_packaging '';
    if (
$this->product->packaging || $this->product->box) { ?>

  <div class="product-packaging">

    <?php
    if (
$this->product->packaging) {
$product_packaging .= JText::_('COM_VIRTUEMART_PRODUCT_PACKAGING1') . $this->product->packaging;
if ($this->product->box)
    $product_packaging .= '<br />';
    }
    if ($this->product->box)
$product_packaging .= JText::_('COM_VIRTUEMART_PRODUCT_PACKAGING2') . $this->product->box;
    echo str_replace("{unit}"$this->product->product_unit $this->product->product_unit JText::_('COM_VIRTUEMART_PRODUCT_FORM_UNIT_DEFAULT'), $product_packaging);
    ?>

        </div>
   <?php // Product Packaging END
    
?>


<?php // Product Files
// foreach ($this->product->images as $fkey => $file) {
// Todo add downloadable files again
// if( $file->filesize > 0.5) $filesize_display = ' ('. number_format($file->filesize, 2,',','.')." MB)";
// else $filesize_display = ' ('. number_format($file->filesize*1024, 2,',','.')." KB)";

/* Show pdf in a new Window, other file types will be offered as download */
// $target = stristr($file->file_mimetype, "pdf") ? "_blank" : "_self";
// $link = JRoute::_('index.php?view=productdetails&task=getfile&virtuemart_media_id='.$file->virtuemart_media_id.'&virtuemart_product_id='.$this->product->virtuemart_product_id);
// echo JHTMl::_('link', $link, $file->file_title.$filesize_display, array('target' => $target));
// }
if (!empty($this->product->customfieldsRelatedProducts)) { ?>

<div class="product-related-products">
<h4 class="title"><?php echo JText::_('COM_VIRTUEMART_RELATED_PRODUCTS'); ?></h4>
<?php
foreach ($this->product->customfieldsRelatedProducts as $field){
?>

<div class="product-field-type-<?php echo $field->field_type ?>">
<span class="product-field-display"><?php echo $field->display ?></span>
<span class="product-field-desc"><?php echo jText::_($field->custom_field_desc?></span>
</div>
<?php
?>

</div>
<?php
// Product customfieldsRelatedProducts END

if (!empty($this->product->customfieldsRelatedCategories)) { ?>

<div class="product-related-categories">
<h4><?php echo JText::_('COM_VIRTUEMART_RELATED_CATEGORIES'); ?></h4>
<?php foreach ($this->product->customfieldsRelatedCategories as $field){ ?>
<div style="display:inline-block;" class="product-field product-field-type-<?php echo $field->field_type ?>">
<span class="product-field-display"><?php echo $field->display ?></span>
<span class="product-field-desc"><?php echo jText::_($field->custom_field_desc?></span>
</div>
<?php
?>

</div>
<?php
// Product customfieldsRelatedCategories END

?>


<?php
echo $this->loadTemplate('reviews');
?>

</div>


[attachment cleanup by admin]