Skip to main content

Create Related Products column in Administrator

More
11 years 11 months ago #174300 by jnascimento
Hello,

I'm trying to change the Administrator products listing to show the related products link in the list. (image in attachment



So far i was able to add the Title by adding the <td> on the right place.

My difficulty now is that i cannot get the related products title in the fields.
I enter this code in the product/listing.php file:

<td align="center">
<?php if($this->manage){ ?>
<a href="<?php echo hikashop_completeLink('product&task=edit&cid[]='.$row->product_related_id); ?>">
<?php } ?>
<?php echo $row->product_name; ?>
<?php if($this->manage){ ?>
</a>
<?php } ?>
</td>

But what i get is only the same product name...
Can you please tell me what can i do to make this possible?

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

More
11 years 11 months ago - 11 years 11 months ago #174342 by Jerome
Hi,

Doing such modification require some development/PHP skills.
You have to perform an SQL query in order to get the related products for the products you will list.
For the moment the code display the product name of the current product in the loop ; but if you do not have loaded the related products, you won't be able to display them.
Code:
$query = 'SELECT a.*,b.* FROM '.hikashop_table('product_related').' AS a LEFT JOIN '.hikashop_table('product').' AS b ON a.product_related_id=b.product_id WHERE a.product_related_type=\'related\' AND a.product_id = '.$row->product_id; $database->setQuery($query); $related_products = $database->loadObjectList();

Regards,

Jerome - Obsidev.com
HikaMarket & HikaSerial developer / HikaShop core dev team.

Also helping the HikaShop support team when having some time or couldn't sleep.
By the way, do not send me private message, use the "contact us" form instead.
Last edit: 11 years 11 months ago by Jerome.

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

More
11 years 11 months ago #174472 by jnascimento
Thanks for the reply.

I'm sorry i'm still "very young" on PHP coding.

I'm trying to apply this to the code but i'm not having results with it.

Im doing this:
Code:
<td> <?php $query = 'SELECT a.*,b.* FROM '.hikashop_table('product_related').' AS a LEFT JOIN '.hikashop_table('product').' AS b ON a.product_related_id=b.product_id WHERE a.product_related_type=\'related\' AND a.product_id = '.$row->product_id; $database->setQuery($query); $related_products = $database->loadObjectList(); ?> <?php echo $row->product_name; ?> </td>

I'm calling the product_name after requesting the query but it's not working.

Can you help with this little bit of code?

Thanks

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

More
11 years 11 months ago - 11 years 11 months ago #174511 by Mohamed Thelji
Hello,
The code that Jerome gave you will just allow you to load the related products details on the "$related_products" object, now you'll just have to check what you have on that object and display the link of your related products.
Using that kind of code will probably do the job :
Code:
$database = JFactory::getDBO(); $query = 'SELECT a.*,b.* FROM '.hikashop_table('product_related').' AS a LEFT JOIN '.hikashop_table('product').' AS b ON a.product_related_id=b.product_id WHERE a.product_related_type=\'related\' AND a.product_id = '.$row->product_id; $database->setQuery($query); $related_products = $database->loadObjectList(); foreach($related_products as $key => $related_product){ if(!empty($related_product)){ ?> <a href="<?php echo hikashop_completeLink('product&task=edit&cid[]='.$related_product->product_id); ?>"> <?php echo $related_product->product_name.'</br>'; ?> </a><?php } }
Last edit: 11 years 11 months ago by Mohamed Thelji.

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

More
11 years 11 months ago #174566 by jnascimento
Thanks for the reply... i try it under the <td></td> and it didn't work... i'm getting a blank page...

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

More
11 years 11 months ago #174623 by jnascimento
IT's working now...

This is what i have done:
Code:
<td> <?php $database = JFactory::getDBO(); $query = 'SELECT a.*,b.* FROM '.hikashop_table('product_related').' AS a LEFT JOIN '.hikashop_table('product').' AS b ON a.product_related_id=b.product_id WHERE a.product_related_type=\'related\' AND a.product_id = '.$row->product_id; $database->setQuery($query); $related_products = $database->loadObjectList(); foreach($related_products as $key => $related_product){ if(!empty($related_product)){ ?> <a href="<?php echo hikashop_completeLink('product&task=edit&cid[]='.$related_product->product_id); ?>"> <?php echo $related_product->product_name.'</br>'; ?> </a> <?php } } ?> </td>

Many thanks for your support!

Best Regards,

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

More
11 years 11 months ago #174639 by Jerome
Hi,

Good to know that it is working now.

When you got full blank page, do not hesitate to check your PHP error log or to activate the Joomla debug mode (in the joomla global configuration).
You can also change the "error reporting" to "maxium" in the Joomla global configuration (server).

Regards,

Jerome - Obsidev.com
HikaMarket & HikaSerial developer / HikaShop core dev team.

Also helping the HikaShop support team when having some time or couldn't sleep.
By the way, do not send me private message, use the "contact us" form instead.

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

Time to create page: 0.246 seconds
Powered by Kunena Forum