Jump to content

a new field for product


pedro fonseca

Recommended Posts

steps:

1. Create a field 'fieldx' in ps_product table;
field name: fieldx
type: decimal
values: 26
default: as defined
0.00000


2. Edit file classes/product.php:
(Line 147 aprox.) added:

public $fieldx; 



(Line 163 aprox.) added to filesize:

'fieldx' => 32



(Line 196 aprox.)

'fieldx' => 'IsGenericName'



(Line 259 aprox.) added to getFields:

$fields['fieldx'] = pSQL($this->fieldx);





3. In admin/tabs/AdminProducts.php around line 1831, insert just an imput like this:

’.$this->l(‘Margen:’).’  
<input type=“text” size=“33” name=“fieldx” value=”’.htmlentities($this->getFieldValue($obj, ‘fieldx’), ENT_COMPAT, ‘UTF-8’).’” > * (’.$this->l(‘Margen one, and two’).’)




have a problem.:
appear a error in backoffice:

"1 error

an error occurred while creating object product"



Part of the code is wrong?

Link to comment
Share on other sites

the field is defined as decimal. what type/how many decimals? how it is defined actually eg: decimal(4, 2); what value are you trying to submit?
you can also turn on sql debugging define('_PS_DEBUG_SQL_', true); in config/config.inc.php

Link to comment
Share on other sites

I really don't understand you. I said: "are you getting the error with any submitted value?"
you just answered no. With what value you don't get the error. With what value do you get the error?

Link to comment
Share on other sites

the idea is for a new field in the product (AdminProduct.php). This field will be called "contribution" (%). When you enter a product choose % for this product. This value (% * price) will appear in the front office, beneath the final product price.

Something like: "By buying this product to help nature Ex.10 €)
understand Otzy?

Link to comment
Share on other sites

Create attribute group "contribution", create attributes with different % values and add desired combination for each product.

>Something like: “By buying this product to help nature Ex.10 €
this may be created by JavaScript after page load. Just change tpl file in your theme folder.
Another way - to write a module with product footer hook function

It seems to me it is better than making modifications in core files.

Link to comment
Share on other sites

One of the possible solutions with combinations:

find code in product.tpl

            {foreach from=$groups key=id_attribute_group item=group}
           {if $group.attributes|@count}


{$group.name|escape:'htmlall':'UTF-8'} :
               {assign var='groupName' value='group_'|cat:$id_attribute_group}
0}$('#wrapResetImages').show('slow');{/if}">
                   {foreach from=$group.attributes key=id_attribute item=group_attribute}
{$group_attribute|escape:'htmlall':'UTF-8'}
                   {/foreach}


           {/if}
           {/foreach}



replace it with this one:

            {foreach from=$groups key=id_attribute_group item=group}
           {if $group.attributes|@count}


               {if $group.name != 'contribution'}{$group.name|escape:'htmlall':'UTF-8'} :{/if}
               {assign var='groupName' value='group_'|cat:$id_attribute_group}
0}$('#wrapResetImages').show('slow');{/if}">
                   {foreach from=$group.attributes key=id_attribute item=group_attribute}
{$group_attribute|escape:'htmlall':'UTF-8'}
                       {if $group.name == 'contribution'}
                           {literal}[removed]
                               $(document).ready(function(){
                                   document.getElementById('contribution_label')[removed]="{/literal}{$group_attribute|escape:'htmlall':'UTF-8'}{literal}"
                               })
                           [removed]{/literal}
                       {/if}
                   {/foreach}


           {/if}
           {/foreach}



and place


wherever you want


I did not test code, this is only the demonstration of idea

Link to comment
Share on other sites

Mr. Otzy,
Create a combination name: "contribution"

the code product.tpl:

{foreach from=$groups key=id_attribute_group item=group}
           {if $group.attributes|@count}


               {if $group.name != 'contribution'}{$group.name|escape:'htmlall':'UTF-8'} :{/if}
               {assign var='groupName' value='group_'|cat:$id_attribute_group}
0}$('#wrapResetImages').show('slow');{/if}">
                   {foreach from=$group.attributes key=id_attribute item=group_attribute}
{$group_attribute|escape:'htmlall':'UTF-8'}
                       {if $group.name == 'contribution'}
                           {literal}. innerHTML $(document).ready(function(){
                                   document.getElementById('contribution_label')[removed]="{/literal}{$group_attribute|escape:'htmlall':'UTF-8'}{literal}"
                               })
                           . innerHTML{/literal}
                       {/if}
                   {/foreach}




page blank. not appear.

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...