Add model under product name in admin

Talk about Hooks. Share Hooks you have made.
User avatar
tessthepup
Certified Developer
Posts: 381
Joined: Mon Mar 01, 2021 5:55 pm
Phoenix Version:
Has thanked: 47 times
Been thanked: 62 times

Add model under product name in admin

Post 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.
You do not have the required permissions to view the files attached to this post.


Join The Code Co-op to get access to your library in the Code Co-op Forum
User avatar
Kofod95
Senior Contributor
Posts: 748
Joined: Sat Feb 06, 2021 7:38 pm
Phoenix Version: 1.0.8.20
Has thanked: 99 times
Been thanked: 179 times

Re: Add model under product name in admin

Post 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
I'm not smart, but sometimes even a blind chicken can find a corn.
Here are a lot of corns: Phoenix user guide
User avatar
tessthepup
Certified Developer
Posts: 381
Joined: Mon Mar 01, 2021 5:55 pm
Phoenix Version:
Has thanked: 47 times
Been thanked: 62 times

Re: Add model under product name in admin

Post 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
You do not have the required permissions to view the files attached to this post.
ecartz
Core Team
Posts: 3084
Joined: Tue Nov 05, 2019 6:02 pm
Phoenix Version:
Has thanked: 4 times
Been thanked: 208 times

Re: Add model under product name in admin

Post 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
User avatar
tessthepup
Certified Developer
Posts: 381
Joined: Mon Mar 01, 2021 5:55 pm
Phoenix Version:
Has thanked: 47 times
Been thanked: 62 times

Re: Add model under product name in admin

Post 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
heatherbell
Senior Contributor
Posts: 2540
Joined: Mon Oct 07, 2019 4:39 am
Phoenix Version:
Has thanked: 35 times
Been thanked: 243 times

Re: Add model under product name in admin

Post 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.
User avatar
tessthepup
Certified Developer
Posts: 381
Joined: Mon Mar 01, 2021 5:55 pm
Phoenix Version:
Has thanked: 47 times
Been thanked: 62 times

Re: Add model under product name in admin

Post 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')];
 }
}
ecartz
Core Team
Posts: 3084
Joined: Tue Nov 05, 2019 6:02 pm
Phoenix Version:
Has thanked: 4 times
Been thanked: 208 times

Re: Add model under product name in admin

Post 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.
User avatar
tessthepup
Certified Developer
Posts: 381
Joined: Mon Mar 01, 2021 5:55 pm
Phoenix Version:
Has thanked: 47 times
Been thanked: 62 times

Re: Add model under product name in admin

Post 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.
User avatar
burt
Core Team
Posts: 4550
Joined: Tue Oct 29, 2019 9:37 am
Phoenix Version: v1.1.0.8
Has thanked: 252 times
Been thanked: 412 times

Re: Add model under product name in admin

Post 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.
I am not here to build for you.
I am here to build with you. Let's help each other.


Join The Code Co-op to get access to your library in the Code Co-op Forum
Post Reply