Page 1 of 3

Add model under product name in admin

Posted: Sat Jul 13, 2024 5:19 pm
by tessthepup
Hi Guys,

I have the need to be able to see the model of the product without editing the product.

I have looked through the admin/includes/actions/catalog/ files but not sure how/where to put the relevant code.

Ideally I would like the products_model either under the product name or above the date added line.

Re: Add model under product name in admin

Posted: Sat Jul 13, 2024 8:11 pm
by Kofod95
You can hook that in. Try watching the end of Zipurs video for the customer data module (how did you find us), where he shows how to hook something into the infoBox.

//Daniel

Re: Add model under product name in admin

Posted: Sun Jul 14, 2024 12:07 pm
by tessthepup
Kofod95 wrote: Sat Jul 13, 2024 8:11 pm You can hook that in. Try watching the end of Zipurs video for the customer data module (how did you find us), where he shows how to hook something into the infoBox.

//Daniel
Cheers Daniel, It helped and worked :)

I would however like the model furthe up either under the product name or above the date added.

Any ideas without changing the core hook placement???

Thanks
Mark

Re: Add model under product name in admin

Posted: Sun Jul 14, 2024 12:45 pm
by ecartz
tessthepup wrote: Sun Jul 14, 2024 12:07 pm Any ideas without changing the core hook placement???
Use array_splice instead of appending.

https://stackoverflow.com/q/1763959/6660678

Re: Add model under product name in admin

Posted: Sun Jul 14, 2024 1:49 pm
by tessthepup
ecartz wrote: Sun Jul 14, 2024 12:45 pm
tessthepup wrote: Sun Jul 14, 2024 12:07 pm Any ideas without changing the core hook placement???
Use array_splice instead of appending.

https://stackoverflow.com/q/1763959/6660678
Lost me with that one pal :o

Re: Add model under product name in admin

Posted: Sun Jul 14, 2024 3:24 pm
by heatherbell
tessthepup wrote: Sun Jul 14, 2024 1:49 pm Lost me with that one pal :o
Maybe that's an unhelpful reply when looking for more help? Not even a thank you?
Look at the StackOverflow link given, there's another link there that goes to https://www.php.net/manual/en/function.array-splice.php which explains its use.
Can only guess that you're using array_push in your hook (shouldn't need to guess, post your code) so try using array_splice instead, use the examples in PHP Manual as a start point.

Re: Add model under product name in admin

Posted: Sun Jul 14, 2024 3:37 pm
by tessthepup
heatherbell wrote: Sun Jul 14, 2024 3:24 pm
tessthepup wrote: Sun Jul 14, 2024 1:49 pm Lost me with that one pal :o
Maybe that's an unhelpful reply when looking for more help? Not even a thank you?
Look at the StackOverflow link given, there's another link there that goes to https://www.php.net/manual/en/function.array-splice.php which explains its use.
Can only guess that you're using array_push in your hook (shouldn't need to guess, post your code) so try using array_splice instead, use the examples in PHP Manual as a start point.
Maybe that's an unhelpful reply when looking for more help? Not even a thank you?
No disrespect intended, sorry
Look at the StackOverflow link given, there's another link there that goes to https://www.php.net/manual/en/function.array-splice.php which explains its use.
Thank you I will look at that.
Can only guess that you're using array_push in your hook (shouldn't need to guess, post your code) so try using array_splice instead, use the examples in PHP Manual as a start point.
I am not using array_push but this

Code: Select all

<?php
class hook_admin_catalog_catalogmodel{
   public function listen_infoBox($parameters) {
     global $product;
	if (isset($product) && ($product Instanceof Product)) $parameters['contents'][] = ['class' => 'style', 'text' => TEXT_CATALOG_PRODUCTS_MODEL . ' ' . $product->get('model')];
 }
}

Re: Add model under product name in admin

Posted: Mon Jul 15, 2024 4:54 am
by ecartz

Code: Select all

if (isset($product) && ($product Instanceof Product)) {
  array_splice($parameters['contents'], 1, 0, [['class' => 'style', 'text' => TEXT_CATALOG_PRODUCTS_MODEL . ' ' . $product->get('model')]]);
}
Change the 1 to other numbers to change where it appears.

Re: Add model under product name in admin

Posted: Mon Jul 15, 2024 5:03 pm
by tessthepup
ecartz wrote: Mon Jul 15, 2024 4:54 am

Code: Select all

if (isset($product) && ($product Instanceof Product)) {
  array_splice($parameters['contents'], 1, 0, [['class' => 'style', 'text' => TEXT_CATALOG_PRODUCTS_MODEL . ' ' . $product->get('model')]]);
}
Change the 1 to other numbers to change where it appears.
Thank you very much. Works perfect.

Re: Add model under product name in admin

Posted: Mon Jul 15, 2024 5:07 pm
by burt
You could also add in a new column to the display table, with a Hook.
So (eg) model could be in between the "name" and the "red/green status" columns.