Jump to content

(SOLVED temporarily) show "manufacture product number" or "MPN" when select a combination


hogo20

Recommended Posts

hello everyone 

I use Combination in my PrestaShop store.

is it possible to show "manufacture product number" or "MPN" code, when select a combination? 

in PrestaShop 8.2 when assign MPN code (or UPC), it does not show anything about that in front office. 

( In the attached picture, my wish is better determined.) 

Thank you for your help 

۲۰۲۵۰۱۲۳_۰۷۲۷۱۰.jpg

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

Hello

Add the code

  {foreach from=$product.specific_references item=reference key=key}

    <dt class="name">{$key}</dt>

    <dd class="value">{$reference}</dd>

  {/foreach}

to your theme file at

themes/our_theme/templates/catalog/_partials/product-variants.tpl

 

Screenshot_8.jpg

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

Hey, did you just do this? 🤔

I clear the cache from:

1- admin =advanced parameter >performance 

2- host= var >cache

But I didn't see any change. Strange! 

I have PrestaShop 8.2 with PHP 8.1.

Should I install and test a new on LocalHost or is there a point? 

Thank you bro 

Link to comment
Share on other sites

Your recommendations code is on:

public_html/themes/classic/templates/catalog/_partials/product-variants.tpl

(In this path, I added some codes to display the inventory of each combination of goods and works fine. So the folder is correct and runs from it.) 

It's also strange to me why it doesn't work. 

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

3 hours ago, Ewonta said:
themes/our_theme/templates/catalog/_partials/product-variants.tpl

Take a close look at the message, I fixed it right away because I didn't know what your theme was.


our_theme

Link to comment
Share on other sites

You obviously have some kind of cache enabled on the server, with hard page caching. 

The product-quantity block is displayed, you have sent a screenshot that you have inserted the code into the required file.

 

<div class="product-quantities" style="font-weight: bolder;">
        <label class="label">In stock</label>
        <span data-stock="1" data-allow-oosp="1">1 Items</span>
      </div>

1) either the code was inserted into the wrong file.

2) Either the server has hard-coded the file

Link to comment
Share on other sites

I gave a ticket to the server administrator and they offered a way to remove the server cache. By doing that, it didn't work. I decided to install and test a fresh version on LocalHost. 

Thank you for your guidance. 🙏

 

Link to comment
Share on other sites

hello, friends

In Prestashop 8.2.0, open file:   /controllers/front/ProductController.php

and remove line 1207 (with this code):

$product['cart_quantity'] = $this->context->cart->getProductQuantity($product['id_product'], $product['id_product_attribute'])['quantity'];

then add this code to: /themes/[your theme]/templates/catalog/_partials/product-variants.tpl

    {block name='product_specific_reference'}
        <p class="product-specific-reference"  style="font-weight: bolder;">
            {foreach from=$product.specific_references item=reference key=key}
            <span class="name">{$key}: </span><span class="value" style="color:#005fff;">{$reference}</span><br/>
            {/foreach}
        </p>
    {/block}

Oper.png

3333.png

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

  • hogo20 changed the title to (SOLVED) show "manufacture product number" or "MPN" when select a combination

Changing the behavior of the system in this way is not the best option, deleting

 /controllers/front/ProductController.php

has nothing to do with

{block name='product_specific_reference'}
        <p class="product-specific-reference"  style="font-weight: bolder;">
            {foreach from=$product.specific_references item=reference key=key}
            <span class="name">{$key}: </span><span class="value" style="color:#005fff;">{$reference}</span><br/>
            {/foreach}
        </p>
    {/block}

It is better not to delete directly, you always need to override classes and controllers.

Link to comment
Share on other sites

  • hogo20 changed the title to show "manufacture product number" or "MPN" when select a combination
On 1/24/2025 at 6:53 PM, hogo20 said:

hello, friends

In Prestashop 8.2.0, open file:   /controllers/front/ProductController.php

and remove line 1207 (with this code):

$product['cart_quantity'] = $this->context->cart->getProductQuantity($product['id_product'], $product['id_product_attribute'])['quantity'];

then add this code to: /themes/[your theme]/templates/catalog/_partials/product-variants.tpl

    {block name='product_specific_reference'}
        <p class="product-specific-reference"  style="font-weight: bolder;">
            {foreach from=$product.specific_references item=reference key=key}
            <span class="name">{$key}: </span><span class="value" style="color:#005fff;">{$reference}</span><br/>
            {/foreach}
        </p>
    {/block}

Oper.png

3333.png

hello, this method make new problem. 

When pre-order is active, The minimum order number is not automatically entered in the relevant box. However, this method can be used to solve it in the next version, hopefully. 

 

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

This feature has nothing to do with your question, it's a mistake.
 

$product['cart_quantity'] = $this->context->cart->getProductQuantity($product['id_product'], $product['id_product_attribute'])['quantity'];

 

Link to comment
Share on other sites

Yes, it's possible to display the MPN code when selecting a combination in PrestaShop, but it may require some custom development. You'll likely need to modify the product.tpl file in your theme and use PrestaShop's hooks to fetch and display the MPN dynamically in the front office.

Link to comment
Share on other sites

  • hogo20 changed the title to (SOLVED temporarily) show "manufacture product number" or "MPN" when select a combination

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