Jump to content

  • You cannot start a new topic
  • You cannot reply to this topic

Custom Field In The Product List Data. Rate Topic   - - - - -

 
  • dataspotgr
  • Advanced Member
  • Authorized Reseller
  • Join Date: 04-Sep 13
  • 65 posts

Posted 05 August 2022 - 08:44 AM #1

Hi, 

 

I have created a new custom field (Checkbox) in the product page (dispatch=products.update) and I'm able to edit this field and store the data in the cscart_products table in the database. Also, the value of this field is still visible in I do {fn_print_r($product_data)} in the product page.

 

Now, I want to edit this value in the Products --> Products (dispatch=products.manage) page. I'm creating the following 2 .tpl files inside my addon's folder on the backend:

 

/hooks/products/manage_body.post.tpl
/hooks/products/manage_head.post.tpl

 

and with that i added the the checkbox and the header on each product. 
 

The problem now is that can't change the value of this checkbox now and i think that is because when I do {fn_print_r($product)} inside the manage_body.post.tpl it prints all the product values/fields but not my custom value.

 

How do I add my custom value in the product array so I can edit it?



 
  • soft-solid
  • Junior Member
  • Authorized Reseller
  • Join Date: 19-Apr 10
  • 1696 posts

Posted 05 August 2022 - 09:41 AM #2

Hello

 

Please show content file /hooks/products/manage_body.post.tpl

 

Best regards

Robert


Team of SoftSolid
cs-cart.pl | marketplace | Multi-Vendor/CS-Cart Development | Dedicated developers

We specialize in creating the highest quality addons, safe, useful and flexible


 
  • dataspotgr
  • Advanced Member
  • Authorized Reseller
  • Join Date: 04-Sep 13
  • 65 posts

Posted 05 August 2022 - 09:51 AM #3

That is the content of /hooks/products/manage_body.post.tpl

<td class="{$no_hide_input_if_shared_product}" style="white-space: nowrap;">
	<input type="hidden" name="products_data[{$product.product_id}][ds_disable_skroutz_xml]" value="N" />
	<span class='cm-tooltip' title="{__("ds_disable_for_skroutz_xml")}"><input type="checkbox" name="products_data[{$product.product_id}][ds_disable_skroutz_xml]" value="Y" {if $product.ds_disable_skroutz_xml == "Y"}checked="checked"{/if}/></span>
	{include file="buttons/update_for_all.tpl" display=$show_update_for_all object_id='ds_disable_skroutz_xml' name="update_all_vendors[ds_disable_skroutz_xml]"}
	{fn_print_r($product)}
</td>


 
  • soft-solid
  • Junior Member
  • Authorized Reseller
  • Join Date: 19-Apr 10
  • 1696 posts

Posted 05 August 2022 - 10:06 AM #4

Hello

 

Did you check on database that value from this fiels is save?

 

Connect in your addon to hook "get_products" and modify the $fields (add your field from database)

 

fn_set_hook('get_products', $params, $fields, $sortings, $condition, $join, $sorting, $group_by, $lang_code, $having);

 

Best regards

Robert


Team of SoftSolid
cs-cart.pl | marketplace | Multi-Vendor/CS-Cart Development | Dedicated developers

We specialize in creating the highest quality addons, safe, useful and flexible


 
  • dataspotgr
  • Advanced Member
  • Authorized Reseller
  • Join Date: 04-Sep 13
  • 65 posts

Posted 05 August 2022 - 10:37 AM #5

Thank you a lot for you replay again.

 

In the init.php file in my addon, when i register the hook i get "Service Unavailable".

 

init.php file:

<?php

if (!defined('BOOTSTRAP')) { die('Access denied'); }

fn_register_hooks(
	'update_product_post',
	'get_products'
);

I already had the "update_product_post" hook registered so, i just added the "get_products"

 

I also cleared cache manualy



 
  • dataspotgr
  • Advanced Member
  • Authorized Reseller
  • Join Date: 04-Sep 13
  • 65 posts

Posted 05 August 2022 - 10:46 AM #6

I found that the error happend because i didn't call the function fn_my_addon_get_products() in the fun.php.

 

I added it and it seems that works fine.



 
  • dataspotgr
  • Advanced Member
  • Authorized Reseller
  • Join Date: 04-Sep 13
  • 65 posts

Posted 05 August 2022 - 11:28 AM #7

Problem sloved!

 

Thank you a lot for your help soft-solid!



 
  • soft-solid
  • Junior Member
  • Authorized Reseller
  • Join Date: 19-Apr 10
  • 1696 posts

Posted 05 August 2022 - 11:34 AM #8

Hello

 

You are welcome :)

 

Best regards

Robert


Team of SoftSolid
cs-cart.pl | marketplace | Multi-Vendor/CS-Cart Development | Dedicated developers

We specialize in creating the highest quality addons, safe, useful and flexible