Jump to content

Adding options to product condition list


KGI

Recommended Posts

Hello Fellow PS users.

 

We recently installed the latest version of PS - the face of it is all sing and dancing but none the less once you get going it not to different to previous versions.

 

However - new for us - and we would like to adapt it a bit, is the function in the product page called Condition.

 

This would be good if PS could make a module to amend, change and add to the 3 items that currently show.

 

We have search here for some data and have found some which slightly preceeds the current version.

 

So if there is any instructions - please can any of you assist.

 

Kind regards

 

Ian

 

Forgot to mention the important bit.

 

We followed through with as much as we could on previous posts - 4 files in all needed changes (closed for reply now) and manged to get new wording in the BO page but it would not save - the DB was manually changed PS_ product and PS_product_shop to add in the one new action

 

Sadly it would not work for us.

Edited by KGI (see edit history)
Link to comment
Share on other sites

You say you added the item to the enums in the ps_product and ps_product_shop tables. Did you also add it to the values array on line 305 (assuming you're using PrestaShop v1.6.1.6) of classes/Product.php?

            'condition' =>                    array('type' => self::TYPE_STRING, 'shop' => true, 'validate' => 'isGenericName', 'values' => array('new', 'used', 'refurbished'), 'default' => 'new'),

I'm assuming you've already changed lines 163-177 (assuming you're using the default PrestaShop v1.6.1.6 theme) of product.tpl:

			{if !$product->is_virtual && $product->condition}
			<p id="product_condition">
				<label>{l s='Condition:'} </label>
				{if $product->condition == 'new'}
					<link itemprop="itemCondition" href="https://schema.org/NewCondition"/>
					<span class="editable">{l s='New product'}</span>
				{elseif $product->condition == 'used'}
					<link itemprop="itemCondition" href="https://schema.org/UsedCondition"/>
					<span class="editable">{l s='Used'}</span>
				{elseif $product->condition == 'refurbished'}
					<link itemprop="itemCondition" href="https://schema.org/RefurbishedCondition"/>
					<span class="editable">{l s='Refurbished'}</span>
				{/if}
			</p>
			{/if}

and lines 316-322 (assuming you're using PrestaShop v1.6.1.6) of themes/default/template/controllers/products/informations.tpl:

				<div class="col-lg-3">
					<select name="condition" id="condition">
						<option value="new" {if $product->condition == 'new'}selected="selected"{/if} >{l s='New'}</option>
						<option value="used" {if $product->condition == 'used'}selected="selected"{/if} >{l s='Used'}</option>
						<option value="refurbished" {if $product->condition == 'refurbished'}selected="selected"{/if}>{l s='Refurbished'}</option>
					</select>
				</div>

and lines 1023-1027 (assuming you're using PrestaShop v1.6.1.6) of modules/blocklayered/blocklayered.php:

					$condition_list = array(
						'new' => $this->translateWord('New', (int)$filter['id_lang']),
						'used' => $this->translateWord('Used', (int)$filter['id_lang']),
						'refurbished' => $this->translateWord('Refurbished', (int)$filter['id_lang'])
					);

I would expect it to work after overriding or editing these files.

Link to comment
Share on other sites

Good Morning - Thank you very much for your reply.

 

So very early this moring I ran through all the data you presented me here.

 

Data Base double checked - new entry added manually in

 

PS_product   and PS_product_shop

 

The added word added via the Structure comand on those two locations which refer to condition enum ....

 

 

Next to double check all words are correctly spelt and showing as you indicated.

 

Two entries to be added within the - classes/Product.php

One entry added within the   - theme / Product.php

 

Via

 

adminxxxxx/themes/ ........../controllers/products.informations.tpl

 

one entry added within above file

 

And 4 entries added to the Blocklayered.php file

 

On the Front office the new wording shows and can be picked - upon saving the data - it defaults back to the first line word - being of course as shown - NEW

 

So is not working for me just yet.

 

 

In the themes ..... / product.tpl file - shown below we have obmitted the data pointing to an out side webe site - data in bold shows the wording we are trying to make work.

 

        {if $product->condition == 'new'}
                    <link itemprop="itemCondition" href="https://schema.org/NewCondition"/>
                    <span class="editable">{l s='New product'}</span>



{if $product->condition == 'new-item-advance'}
                
                    <span class="editable">{l s='New Item Advance Order Only'}</span>







                {elseif $product->condition == 'used'}
                    <link itemprop="itemCondition" href="https://schema.org/UsedCondition"/>
                    <span class="editable">{l s='Used'}</span>
                {elseif $product->condition == 'refurbished'}
                    <link itemprop="itemCondition" href="https://schema.org/RefurbishedCondition"/>
                    <span class="editable">{l s='Refurbished'}</span>

 

 

 

Any mor thoughts on this - would be most helpful - thanking you inadvance

 

Kind regards

 

Ian

Link to comment
Share on other sites

I have no idea why it isn't working. You can send me your FTP details in a private message if you'd like me to double-check your code, or I can mess around on my test site tomorrow and see if I can get it to work.

Link to comment
Share on other sites

HI - I changed wording for very simple text - to ensure no typo erros.

 

I notice that in falie Themes .... product.tpl

 

The coding

href="https://schema.org/NewCondition"/>
                    <span class="editable">{l s='New product'}</span>

 

Shows the words New product - product with a small p

 

I changed this to a capital P so it perhaps would show up on the FO as New Product - but it remained the same.

 

 

In all the other 3 files that have been changed there is no wording of New product

 

 

Is there another file - we have not changed

 

A fith one ??

Link to comment
Share on other sites

You changed "New product" to "New Product" in product.tpl and it still says "New product" on your product page? It sounds like you have the cache enabled. Make sure you go to the Advanced Parameters > Performance tab and click the "Clear cache" button after making any modifications.

Link to comment
Share on other sites

Hi again - thank you for all the time you are assisting me

 

We cahnged that file again and cleared the cache as requested.

 

We then went to a item and changed it status - and searched for that item in FO but the page would not open and hung.......

 

 

Reverted all 4 files back to original PS format (they were saved under ext name) and site back fully working again.

 

 

There is more to this than meets the eye - and we need to assess this further.

 

If you can play with this all well and good and let us know how you do

 

Clearly there is an openning for someone here to make a friendly module to add/ amend this very import section within the latest PS 16.16 V

 

As always - many thanks

 

 

Ian

 

 

We still looking at this though :)

Link to comment
Share on other sites

I just tried doing this on my PrestaShop v1.6.1.6 test site and it works fine. I added a new value 'test' to the condition enum in ps_product and ps_product_shop. I also added 'test' to the 'values' array in classes/Product.php and a new condition 'Test' with the value 'test' in informations.tpl. After doing this, I was able set the condition to "Test" and when I saved the page, it remained on "Test" and I saw the value 'test' save correctly in ps_product and ps_product_shop.

 

I don't understand why it's not working for you. I did notice that if I remove 'test' from the ps_product_shop table, but left it in the ps_product table, saving "Test" didn't work and it reset to "New", so I'd double-check those two tables.

Link to comment
Share on other sites

Hi - Thank you for checking this on your own system - I hope to have another crake at this on our system either this weekend or on Monday - but I would be very grateful should you post the actual script changes you made on here for me to view and see where I went wrong.

 

Would you be able do this please.

 

Many thanks

 

Ian

Edited by KGI (see edit history)
Link to comment
Share on other sites

On my PrestaShop v1.6.1.6 test site, I edited the ps_product and ps_product_shop tables and changed the "Length/Values" of the "condition" column from 'new','used','refurbished' to 'new','used','refurbished','test'. I then changed line 305 of classes/Product.php from:
            'condition' =>                    array('type' => self::TYPE_STRING, 'shop' => true, 'validate' => 'isGenericName', 'values' => array('new', 'used', 'refurbished'), 'default' => 'new'),

to:

            'condition' =>                    array('type' => self::TYPE_STRING, 'shop' => true, 'validate' => 'isGenericName', 'values' => array('new', 'used', 'refurbished', 'test'), 'default' => 'new'),

and lines 317-321 of admin/themes/default/template/controllers/products/informations.tpl from:

					<select name="condition" id="condition">
						<option value="new" {if $product->condition == 'new'}selected="selected"{/if} >{l s='New'}</option>
						<option value="used" {if $product->condition == 'used'}selected="selected"{/if} >{l s='Used'}</option>
						<option value="refurbished" {if $product->condition == 'refurbished'}selected="selected"{/if}>{l s='Refurbished'}</option>
					</select>

to:

					<select name="condition" id="condition">
						<option value="new" {if $product->condition == 'new'}selected="selected"{/if} >{l s='New'}</option>
						<option value="used" {if $product->condition == 'used'}selected="selected"{/if} >{l s='Used'}</option>
						<option value="refurbished" {if $product->condition == 'refurbished'}selected="selected"{/if}>{l s='Refurbished'}</option>
						<option value="test" {if $product->condition == 'test'}selected="selected"{/if}>{l s='Test'}</option>
					</select>

and lines 163-177 of themes/default-bootstrap/product.tpl from:

			{if !$product->is_virtual && $product->condition}
			<p id="product_condition">
				<label>{l s='Condition:'} </label>
				{if $product->condition == 'new'}
					<link itemprop="itemCondition" href="https://schema.org/NewCondition"/>
					<span class="editable">{l s='New product'}</span>
				{elseif $product->condition == 'used'}
					<link itemprop="itemCondition" href="https://schema.org/UsedCondition"/>
					<span class="editable">{l s='Used'}</span>
				{elseif $product->condition == 'refurbished'}
					<link itemprop="itemCondition" href="https://schema.org/RefurbishedCondition"/>
					<span class="editable">{l s='Refurbished'}</span>
				{/if}
			</p>
			{/if}
to:
			{if !$product->is_virtual && $product->condition}
			<p id="product_condition">
				<label>{l s='Condition:'} </label>
				{if $product->condition == 'new'}
					<link itemprop="itemCondition" href="https://schema.org/NewCondition"/>
					<span class="editable">{l s='New product'}</span>
				{elseif $product->condition == 'used'}
					<link itemprop="itemCondition" href="https://schema.org/UsedCondition"/>
					<span class="editable">{l s='Used'}</span>
				{elseif $product->condition == 'refurbished'}
					<link itemprop="itemCondition" href="https://schema.org/RefurbishedCondition"/>
					<span class="editable">{l s='Refurbished'}</span>
				{elseif $product->condition == 'test'}
					<link itemprop="itemCondition" href="https://schema.org/TestCondition"/>
					<span class="editable">{l s='Test'}</span>
				{/if}
			</p>
			{/if}

After doing this and changing the "Condition" of a product to "Test", I see the following on the product page:

 

post-13933-0-48216900-1466831487_thumb.jpg

 

If you're using the Layered Navigation Block, you should also change lines 1023-1027 of modules/blocklayered/blocklayered.php from:

					$condition_list = array(
						'new' => $this->translateWord('New', (int)$filter['id_lang']),
						'used' => $this->translateWord('Used', (int)$filter['id_lang']),
						'refurbished' => $this->translateWord('Refurbished', (int)$filter['id_lang'])
					);

to:

					$condition_list = array(
						'new' => $this->translateWord('New', (int)$filter['id_lang']),
						'used' => $this->translateWord('Used', (int)$filter['id_lang']),
						'refurbished' => $this->translateWord('Refurbished', (int)$filter['id_lang']),
						'test' => $this->translateWord('Test', (int)$filter['id_lang'])
					);
Edited by rocky (see edit history)
Link to comment
Share on other sites

Thank you for posting the script you used - we are suing this to assist us get this right

 

We note there is no change to Blocklayered.php file within the modules/blocklayered

 

Is this correct

 

 

Also we ask about this entry of yours

 

  •                 {elseif $product->condition == 'test'}
  •                     <link itemprop="itemCondition" href="https://schema.org/TestCondition"/>
  •                     <span class="editable">{l s='Test'}</span>

 

Which has the link on line 2 as shown - is this link required and if it is - what about using the wording "NEW release adance orders accepted"

 

 

Please advise further - Many thanks

 

 

Ian

Edited by KGI (see edit history)
Link to comment
Share on other sites

Oops, I forgot to change blocklayered.php. I'll edit my post above and add it.

 

I don't fully understand the <link itemprop=""> myself. You could probably remove it altogether, but it must serve some purpose for PrestaShop to add it. I hope someone else can explain what it's for.

Link to comment
Share on other sites

Hi -

 

There still must be an error

 

the Classes/product.php

 

When changed blocks the site from openning only white page

 

            'condition' =>                    array('type' => self::TYPE_STRING, 'shop' => true, 'validate' => 'isGenericName', 'values' => array('new', 'used', 'refurbished', 'test'), 'default' => 'new'),
 

 

 

The above is the script - which seems okay.  (with word test added)

 

All other files as per your post where changed as was the DB amended for the word test inserted last of course

 

Seems a strange for us.

 

perhaps blocklayeres should also be done?

 

Regards

 

Ian

Link to comment
Share on other sites

Hi again - many thanks for all the information you gave - seems we must be doing something wrong to be able to insert a totally new Condition

 

In the shorter term we managed to adjust the already entered displayed text as shown on front office on each file card.

 

This works for us for now

 

 

Next question - has been asked by the team - any infromation on changing the actual colour of the dispaly text after the work Condition - we wish to change it to Red

 

Any ideas please

Link to comment
Share on other sites

Assuming you're using the default PrestaShop v1.6.1.6 theme, add the following CSS to product.css in your theme:

#product_condition span { color: red }

If you're using a third-party theme without <p id="product_condition"> in product.tpl, then you'll have to add it.

Link to comment
Share on other sites

Hi - thank you for this infromation.

Yes we are using the default theme at present

 

What is the location address of the product.css file please

 

Looking for this one where we have been working - it is not listed - as this version of PS is new for us we are still learning the location of several files.

 

So assistance for this location would be handy - thank you

 

Regards

 

Ian

 

Edited - shortly after posting

 

We found it

 

themes/default-bootstrap/css folder

 

and now attemping the change - Thanks again :)

 

 

We added the script as advised into the product.css file - cleared the cashe - but it did not change the colour on the front page - we presumed we put it in the right place

 

Any further advice on this ......

Edited by KGI (see edit history)
Link to comment
Share on other sites

Thanks for the quick reply - we edited the post you replied to as such

 

Edited - shortly after posting

 

We found it

 

themes/default-bootstrap/css folder

 

and now attemping the change - Thanks again :)

 

 

We added the script as advised into the product.css file - cleared the cashe - but it did not change the colour on the front page - we presumed we put it in the right place

 

Any further advice on this ......

Link to comment
Share on other sites

It's working fine on my test site. I added the following to the bottom of themes/default-bootstrap/css/product.css:

#product_condition span { color: red }

I then see the following:

 

post-13933-0-74679600-1467175944_thumb.png

 

I don't understand why you're having trouble getting things working.  :(

Link to comment
Share on other sites

Hi - Again - many thanks for your very quick reply

 

We under take another attempt

 

product,
    #product.content_only section.primary_block div.pb-right-column .box-info-product {
      border-top-width: 1px;
      min-height: 1px; } }
/***** IE code ****/
.ie8 .pb-left-column #image-block #view_full_size .span_link {
  background: #fff;
  border: 1px solid #d6d4d4; }
.ie8 .box-security {
  filter: none; }

#product_condition span { color: red }

/*# sourceMappingURL=product.css.map */

 

 

And the above is where we have put the script - hopefully the same as you wrote.

 

 

So the result is perfect

 

if you check herpa.online looksearch for article 529457 - you will see it to has worked.

 

VERY BIG THANK YOU :)

Link to comment
Share on other sites

Hi - Again - many thanks for your very quick reply

 

We under take another attempt

 

product,
    #product.content_only section.primary_block div.pb-right-column .box-info-product {
      border-top-width: 1px;
      min-height: 1px; } }
/***** IE code ****/
.ie8 .pb-left-column #image-block #view_full_size .span_link {
  background: #fff;
  border: 1px solid #d6d4d4; }
.ie8 .box-security {
  filter: none; }

#product_condition span { color: red }

/*# sourceMappingURL=product.css.map */

 

 

And the above is where we have put the script - hopefully the same as you wrote.

 

 

So the result is perfect

 

if you check herpa.online looksearch for article 529457 - you will see it to has worked.

 

VERY BIG THANK YOU :)

Link to comment
Share on other sites

  • 2 weeks later...

Hi - We are back on the case of adding addition conditions

 

five in total (one two three four five)

 

We numbered them like this as it is easy to change the text in BO translations.( come on PS staff add 5 like this as a default on PS downloads - it would help your users)

 

Now we have got it working

 

The only file we cannot load up is

 

Modules/blocklayered/blocklayered.php

 

Here is the text we wanted to upload

 

                case 'condition':
                    $condition_list = array(
                        'new' => $this->translateWord('New', (int)$filter['id_lang']),
                        'used' => $this->translateWord('Used', (int)$filter['id_lang']),
                        'refurbished' => $this->translateWord('Refurbished', (int)$filter['id_lang'])
                        'one' => $this->translateWord('one', (int)$filter['id_lang']),
                        'two' => $this->translateWord('two', (int)$filter['id_lang']),
                        'three' => $this->translateWord('three', (int)$filter['id_lang']),
                        'four' => $this->translateWord('four', (int)$filter['id_lang']),
                        'five' => $this->translateWord('five', (int)$filter['id_lang']),
                    );
 

 

But when iploaded the front office (ie:web site does not open at all)

 

However - if we leave the data out and keep it as original file - as stated above - our amendments actually work

 

Do you have any ideas about this ????

 

 

 

Please come back - as we are 99% there now

 

Many thanks

 

Ian

Link to comment
Share on other sites

The error is because you're missing a comma at the end of the 'refurbished' line:

 

case 'condition':
                    $condition_list = array(
                        'new' => $this->translateWord('New', (int)$filter['id_lang']),
                        'used' => $this->translateWord('Used', (int)$filter['id_lang']),
                        'refurbished' => $this->translateWord('Refurbished', (int)$filter['id_lang']),
                        'one' => $this->translateWord('one', (int)$filter['id_lang']),
                        'two' => $this->translateWord('two', (int)$filter['id_lang']),
                        'three' => $this->translateWord('three', (int)$filter['id_lang']),
                        'four' => $this->translateWord('four', (int)$filter['id_lang']),
                        'five' => $this->translateWord('five', (int)$filter['id_lang']),
                    );

Link to comment
Share on other sites

Good Morning - thank you for getting back to me.

 

I am not sure how the coma was deleted - but none the less - it is back in place.

 

case 'condition':
                    $condition_list = array(
                        'new' => $this->translateWord('New', (int)$filter['id_lang']),
                        'used' => $this->translateWord('Used', (int)$filter['id_lang']),
                        'refurbished' => $this->translateWord('Refurbished', (int)$filter['id_lang']),
                        'one' => $this->translateWord('one', (int)$filter['id_lang']),
                        'two' => $this->translateWord('two', (int)$filter['id_lang']),
                        'three' => $this->translateWord('three', (int)$filter['id_lang']),
                        'four' => $this->translateWord('four', (int)$filter['id_lang']),
                        'five' => $this->translateWord('five', (int)$filter['id_lang']),
                    );

 

uploaded the file again - but the site performed the same - white hung blank page.

 

Reverted back to orginal file (which only shows the three defaulted lines of data - and site agin works as normal

 

Now I know you have been on this case with me - and I think you very much for all the help you have given.

 

But it seem so strange that the other 3 files that are changed and the 2 DB tables ahanged and it all works fine - is that not strange......

 

 

Any further ideas are welcome

 

 

Ian

Link to comment
Share on other sites

Hi - this was a good idea of yours - thank you

 

here is the report as requested

 

Parse error: syntax error, unexpected ''one'' (T_CONSTANT_ENCAPSED_STRING), expecting ')' in /home/herpa/public_html/modules/blocklayered/blocklayered.php on line 2514

 

Here is the linage

2508 - 2519

 

                case 'condition':
                    $condition_array = array(
                        'new' => array('name' => $this->l('New'),'nbr' => 0),
                        'used' => array('name' => $this->l('Used'), 'nbr' => 0),
                        'refurbished' => array('name' => $this->l('Refurbished'),
                        'nbr' => 0)
                        'one' => array('name' => $this->l('one'),'nbr' => 0),
                        'two' => array('name' => $this->l('two'),'nbr' => 0),
                        'three' => array('name' => $this->l('three'),'nbr' => 0),
                        'four' => array('name' => $this->l('four'),'nbr' => 0),
                        'five' => array('name' => $this->l('five'),'nbr' => 0),
                    );
 

 

this is line 2514 -                         'one' => array('name' => $this->l('one'),'nbr' => 0),

 

 

regards

 

Ian

Link to comment
Share on other sites

Hi - Well it just goes to show - how a simple , can casue such trouble.

 

case 'condition':
                    $condition_array = array(
                        'new' => array('name' => $this->l('New'),'nbr' => 0),
                        'used' => array('name' => $this->l('Used'), 'nbr' => 0),
                        'refurbished' => array('name' => $this->l('Refurbished'),
                        'nbr' => 0),
                        'one' => array('name' => $this->l('one'),'nbr' => 0),
                        'two' => array('name' => $this->l('two'),'nbr' => 0),
                        'three' => array('name' => $this->l('three'),'nbr' => 0),
                        'four' => array('name' => $this->l('four'),'nbr' => 0),
                        'five' => array('name' => $this->l('five'),'nbr' => 0),
                    );

 

The dat is now correct and posted here for others to use and read.

 

However,

 

It is very important to all who read this that I would not have been able to complete this task with out the huge support from Nethercott Constructions - PrestaShop modules and guides

 

He has answered the various requests for help very quickly ; and a VERY BIG THANK YOU IS GIVEN TO YOU for all this help

 

Which means if you want to see the modules this chap has - he is there to help and support you - he knows his stuff :)

 

Thank you

 

regards

 

 

Ian

Edited by KGI (see edit history)
Link to comment
Share on other sites

  • 1 year later...
  • 4 months later...
On 27/09/2017 at 3:23 PM, qualityangel said:

Hi all,

 

Anyone that can tel me were i can find informations.tpl in prestashop 1.7.2?
I have added options to the db product and product_shop condition enum.

 

Now i only have to edit the backoffice product page selectbox

I've tried to do the same, ..., BUT no way to find this file. I've found an "informations.tpl" file but not the right one.

Have you found a solution by your own, by an other way ?

Would be very helpful !

Link to comment
Share on other sites

  • 3 years later...
  • 2 years later...

For Prestashop 1.7.5

 

1. Add State in Database:

  - Open the ps_product and ps_product_shop tables in your database.

  - Modify the condition column to include the new state, such as "test".

2. Modify ProductOptions.php File:

  - Open the file src\PrestaShopBundle\Form\Admin\Product\ProductOptions.php.

  - Locate the line with 'condition', FormType\ChoiceType::class.

  - Add the new option to the choices array: $this->translator->trans('Test', [], 'Shop.Theme.Catalog') => 'test',.

3. Update the Product Class:

  - Open the file classes\Product.php.

  - Find the line stating 'condition' => array(...).

  - Add "test" to the list of possible values for condition, e.g., 'values' => array('new', 'used', 'refurbished', 'test').

Edited by okz (see edit history)
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...