Jump to content

How to create custom product customization module (possible bugs?)


Recommended Posts

Hi. I need some help.

I'm trying to create a module for Prestashop 8.0.0 somewhat similar to https://addons.prestashop.com/en/combinaisons-customization/30960-additional-product-attributes-custom-product-fields.html.
 

Several modules show it can be done but I'm close to giving up on the project because everything I think I need to modify/hook in the front office is poorly documented in the DevDocs ( product customization, front office templates, front office overrides ).

 

I've managed to find a partial forum post guide https://www.prestashop.com/forums/topic/549666-guide-the-new-customization-system-in-prestashop-17 and the following code snippet in classes/Product.php on how to store and display custom module data somewhere:

foreach ($result as $row) {
	if ((int) $row['id_module'] && (int) $row['type'] == Product::CUSTOMIZE_TEXTFIELD) {
		// Hook displayCustomization: Call only the module in question
		// When a module saves a customization programmatically, it should add its ID in the `id_module` column
		$row['value'] = Hook::exec('displayCustomization', ['customization' => $row], (int) $row['id_module']);
	}
	$customized_datas[(int) $row['id_product']][(int) $row['id_product_attribute']][(int) $row['id_address_delivery']][(int) $row['id_customization']]['datas'][(int) $row['type']][] = $row;
}

 

The solution appears to be define a customization_field entry programatically with is_module = 1 and hook into displayCustomization.

 

I'm now running into several serious problems on how to proceed which make me doubt if it is currently possible to implement in Prestashop 8.0.0 without making hacky modifications.

 

1. I've looked in the product page templates but there is no hook for displayCustomization or anything similar.

2. I try to create a customization_field programatically as described using is_module = 1 with the hook actionProductSave but the row is immediately removed by Prestashop during a cleanup call. It's possibly a bug where the cleanup call is not ignoring module controlled ps_customization_field records but I'm not sure.

 

Any help or suggestions with possible solutions is greatly appreciated.

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...