Post by raconul » Sat Jan 16, 2021 7:56 pm

Hi all,
I'm using OC 3.0.2.0 - Default theme

I'm trying to find a way of entering the Product > Data > Model field in multi-languages - same as the fields from the General Tab
Image
Maybe moving the Model field in the General Tab - under the Product's Name where there are separate tabs for each language.
Image
However, I don't know how to make it function properly as I don't have much PHP knowledge.

Can anyone please advise on how can I achieve this?
Thanks!

User avatar
New member

Posts

Joined
Thu May 18, 2017 1:54 am

Post by OSWorX » Sat Jan 16, 2021 8:24 pm

raconul wrote:
Sat Jan 16, 2021 7:56 pm
I'm trying to find a way of entering the Product > Data > Model field in multi-languages ..
Why?
Model is a unique term in all languages.
E.g.: part001-123-abc
What will you translate here - and what for?

Full Stack Web Developer :: Dedicated OpenCart Development & Support DACH Region
Contact for Custom Work / Fast Support.


User avatar
Administrator

Posts

Joined
Mon Jan 11, 2010 10:52 pm
Location - Austria

Post by xxvirusxx » Sat Jan 16, 2021 8:42 pm

The model is same for any language:
Example:

IdeaPad Flex 5 14ARE05

Upgrade Service | OC 2.3.0.2 PHP 8 | My Custom OC 3.0.3.8 | Buy me a beer


User avatar
Expert Member

Posts

Joined
Tue Jul 17, 2012 10:35 pm
Location - România

Post by raconul » Sat Jan 16, 2021 8:43 pm

Hi OSWorX,
I'm using the model field for describing the type of the product.
Example: If I have a painting - product name "Sunset" and under its name will appear the model type: acrylic painting
or if I have a tshirt and I call it The Shining - under the product name the model would be "t-shirt".
I've added {{ model }} under the Name of the product on each module.
And I need this to be translated.

Am I doing it wrong? If yes, can you please suggest the right way of achieving this?
Thanks.

User avatar
New member

Posts

Joined
Thu May 18, 2017 1:54 am

Post by xxvirusxx » Sat Jan 16, 2021 8:52 pm

I this case you can replicate multi language Name code to Model code.

Upgrade Service | OC 2.3.0.2 PHP 8 | My Custom OC 3.0.3.8 | Buy me a beer


User avatar
Expert Member

Posts

Joined
Tue Jul 17, 2012 10:35 pm
Location - România

Post by straightlight » Sat Jan 16, 2021 9:35 pm

I may have to address here that model / sku can be produced by languages. The only problematic with this is a modified sku not being provided by its original language source might still be considered a modified product by store owners prior or during the sales.

Dedication and passion goes to those who are able to push and merge a project.

Regards,
Straightlight
Programmer / Opencart Tester


Legendary Member

Posts

Joined
Mon Nov 14, 2011 11:38 pm
Location - Canada, ON

Post by OSWorX » Sat Jan 16, 2021 10:03 pm

raconul wrote:
Sat Jan 16, 2021 8:43 pm
Hi OSWorX,
I'm using the model field for describing the type of the product.
Example: If I have a painting - product name "Sunset" and under its name will appear the model type: acrylic painting
or if I have a tshirt and I call it The Shining - under the product name the model would be "t-shirt".
I've added {{ model }} under the Name of the product on each module.
And I need this to be translated.

Am I doing it wrong? If yes, can you please suggest the right way of achieving this?
Thanks.
As said, the model is a unique term and in 99% the same in all languages (because mostly defined by the producer).
What are you doing is the "misuse" this field.
Could be, but not should be.
I would use for such an Attribute and display that below the name - they can be translated into any language.

Full Stack Web Developer :: Dedicated OpenCart Development & Support DACH Region
Contact for Custom Work / Fast Support.


User avatar
Administrator

Posts

Joined
Mon Jan 11, 2010 10:52 pm
Location - Austria

Post by raconul » Sun Jan 17, 2021 2:18 am

Thanks for the replies.
OSWorX, the Attribute solution sounds good.
Any ideea why {{ attribute.text }} does not work if I add it under {{ heading_title }} in product.twig ?
I'm guessing that I still need to define something in the product.php, but don't know exactly what.
Thanks in advance.

User avatar
New member

Posts

Joined
Thu May 18, 2017 1:54 am

Post by straightlight » Sun Jan 17, 2021 2:55 am

raconul wrote:
Sun Jan 17, 2021 2:18 am
Thanks for the replies.
OSWorX, the Attribute solution sounds good.
Any ideea why {{ attribute.text }} does not work if I add it under {{ heading_title }} in product.twig ?
I'm guessing that I still need to define something in the product.php, but don't know exactly what.
Thanks in advance.
Because the attribute.text is loaded under the attribute loop statement in the TWIG file. Calling this variable outside of the loop, the output won't be found.

Dedication and passion goes to those who are able to push and merge a project.

Regards,
Straightlight
Programmer / Opencart Tester


Legendary Member

Posts

Joined
Mon Nov 14, 2011 11:38 pm
Location - Canada, ON

Post by raconul » Sun Jan 17, 2021 3:31 am

Because the attribute.text is loaded under the attribute loop statement in the TWIG file. Calling this variable outside of the loop, the output won't be found.
Oh I see. So now I've added it like this to the product.twig and the text appears as expected:

Code: Select all

{% if attribute_groups %}
                {% for attribute_group in attribute_groups %}
                {% for attribute in attribute_group.attribute %}
                  <p>{{ attribute.text }}</p>
                {% endfor %}
                {% endfor %}          
            {% endif %}
However, I still need to add it on all places like "featured, latest, search, special, related" under the Products name. Hmm. As I can see adding the above code on these twig files does not work. So I'm guessing that I need to define the variable in the php files or something like that? Right?
Thanks.

User avatar
New member

Posts

Joined
Thu May 18, 2017 1:54 am

Post by sw!tch » Sun Jan 17, 2021 4:08 am

You would need to pull in attribute_groups to your controller for those files and put into the products loop.

ex:
controller product loop

Code: Select all

 $attribute_groups = $this->model_catalog_product->getProductAttributes($product_id);

Code: Select all

$data['products'][] = array( ....
            'attribute_groups'  => $attribute_groups,
....
twig product loop

Code: Select all

{% if product.attribute_groups %}
  {% for attribute_group in product.attribute_groups %}
    {% for attribute in attribute_group.attribute %}
      <p>{{ attribute.text }}</p>
    {% endfor %}
  {% endfor %}
{% endif %}
If you don't want to edit the core, events would actually work good for this.
https://github.com/opencart/opencart/wiki/Events-System
-

Backup and learn how to recover before you make any changes!


Active Member

Posts

Joined
Sat Apr 28, 2012 2:32 pm

Post by straightlight » Sun Jan 17, 2021 7:21 am

Events may not work with other extension modules that are pulling $setting in the index method. OCMod might be more ideal in this case.

Dedication and passion goes to those who are able to push and merge a project.

Regards,
Straightlight
Programmer / Opencart Tester


Legendary Member

Posts

Joined
Mon Nov 14, 2011 11:38 pm
Location - Canada, ON
Who is online

Users browsing this forum: No registered users and 14 guests