Add custom-field to product /listing_img_title.php

  • Posts: 22
  • Thank you received: 0
7 years 9 months ago #260317

-- HikaShop version -- : 2.6.4
-- Joomla version -- : 3.6.5
-- PHP version -- : 5.5

I want to add custom-filed display in listing_img_title.php
I have added the following code in php , but can't display $this->element->myfield , always empty

what else code do I need to add!!



foreach ($this->fields as $fieldName => $oneExtraField) {
$value = '';
if(empty($this->element->$fieldName) && !empty($this->element->main->$fieldName))$this->element->$fieldName = $this->element->main->$fieldName;
if(isset($this->element->$fieldName))
$value = trim($this->element->$fieldName);
if(!empty($value)){
$hide_specs = 0;
break;
}
}

Please Log in or Create an account to join the conversation.

  • Posts: 82863
  • Thank you received: 13372
  • MODERATOR
7 years 9 months ago #260323

Hi,

The variable $this->element contains the data of the main category of the listing.
So if your listing is displaying the products of the category X, $this->element will contain the data of that category X.
If you want the data of the product being displayed, you'll find it in $this->row
So the code should be $this->row->myfield instead of $this->element->myfield

Such code should do it:

<?php echo $this->row->myfield; ?>

Please Log in or Create an account to join the conversation.

Time to create page: 0.059 seconds
Powered by Kunena Forum