Hello
I tried to display product SKU in product neighbors.
i eddited
public_html/templates/yourtemplate/html/com_virtuemart/productdetails/default.php
<?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, FALSE);
echo JHtml::_('link', $prev_link, $this->product->neighbours ['previous'][0]
['product_name'], array('rel'=>'prev', 'class' => 'previous-page','data-dynamic-update' => '1'));
}
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, FALSE);
echo JHtml::_('link', $next_link, $this->product->neighbours ['next'][0] ['product_name'], array('rel'=>'next','class' => 'next-page','data-dynamic-update' => '1'));
}
?>
<div class="clear"></div>
</div>
<?php } // Product Navigation END
?>
I changed [product_name] to [product_sku] but it didnt work.
Any help please?
I want to display product_name and product_sku
Any help please?
Replace the codes you posted by the following codes. That should do the trick.
<?php if (VmConfig::get('product_navigation', 1)) : ?>
<div class="product-neighbours">
<?php
// Get an instance of product model
$product_model = (!empty($this->product_model) && is_object($this->product_model)) ? $this->product_model : VmModel::getModel('product');
if (!empty($this->product->neighbours ['previous'][0]))
{
$prev_product_id = $this->product->neighbours ['previous'][0] ['virtuemart_product_id'];
$prev_product = $product_model->getProduct($prev_product_id, true, false, true);
$prev_link = JRoute::_('index.php?option=com_virtuemart&view=productdetails&virtuemart_product_id=' . $prev_product_id . '&virtuemart_category_id=' . $this->product->virtuemart_category_id, false);
echo JHtml::_('link', $prev_link, $prev_product->product_sku, array('rel'=>'prev', 'class' => 'previous-page','data-dynamic-update' => '1'));
}
if (!empty($this->product->neighbours ['next'][0]))
{
$next_product_id = $this->product->neighbours ['next'][0] ['virtuemart_product_id'];
$next_product = $product_model->getProduct($next_product_id, true, false, true);
$next_link = JRoute::_('index.php?option=com_virtuemart&view=productdetails&virtuemart_product_id=' . $next_product_id . '&virtuemart_category_id=' . $this->product->virtuemart_category_id, false);
echo JHtml::_('link', $next_link, $next_product->product_sku, array('rel'=>'next','class' => 'next-page','data-dynamic-update' => '1'));
}
?>
<div class="clear"></div>
</div>
<?php endif ?>
If you want to display product name before SKU then you can use the following codes.
<?php if (VmConfig::get('product_navigation', 1)) : ?>
<div class="product-neighbours">
<?php
// Get an instance of product model
$product_model = (!empty($this->product_model) && is_object($this->product_model)) ? $this->product_model : VmModel::getModel('product');
if (!empty($this->product->neighbours ['previous'][0]))
{
$prev_product_id = $this->product->neighbours ['previous'][0] ['virtuemart_product_id'];
$prev_product = $product_model->getProduct($prev_product_id, true, false, true);
$prev_link = JRoute::_('index.php?option=com_virtuemart&view=productdetails&virtuemart_product_id=' . $prev_product_id . '&virtuemart_category_id=' . $this->product->virtuemart_category_id, false);
echo JHtml::_('link', $prev_link, $prev_product->product_name . ' (' . $prev_product->product_sku . ')', array('rel'=>'prev', 'class' => 'previous-page','data-dynamic-update' => '1'));
}
if (!empty($this->product->neighbours ['next'][0]))
{
$next_product_id = $this->product->neighbours ['next'][0] ['virtuemart_product_id'];
$next_product = $product_model->getProduct($next_product_id, true, false, true);
$next_link = JRoute::_('index.php?option=com_virtuemart&view=productdetails&virtuemart_product_id=' . $next_product_id . '&virtuemart_category_id=' . $this->product->virtuemart_category_id, false);
echo JHtml::_('link', $next_link, $next_product->product_name . ' (' . $next_product->product_sku . ')', array('rel'=>'next','class' => 'next-page','data-dynamic-update' => '1'));
}
?>
<div class="clear"></div>
</div>
<?php endif ?>
Worked like a charm:) thank you mate