cancel
Showing results for 
Search instead for 
Did you mean: 

Custom module multistore language

Custom module multistore language

 

I already created a module with two store views (PT / EN) but I am having difficulty completing the module with the functionality of saving the module fields as well as the products.

Example:
- when I save a product I can put the description in PT and EN by choosing the store view in the top of administration of magento2 (Back-Office) .

 

How can I create this same functionality in my module?

Does anyone help me find this information?

5 REPLIES 5

Re: Custom module multistore language

Hi @Peleja,

 

I understand what you're trying to build.

Can you share some insights about your module?

Are you suing an EAV strucutre or is a flat table module?

 

Re: Custom module multistore language

Hi Damian thank you or reply,

 

I have a simple structure.

I have done an module that save posts equivalent to Mageplaza template :

https://www.mageplaza.com/magento-2-module-development/create-admin-grid-magento-2.html

After your reply i am searching about EAV attributes and i found that:

 

$eavSetup->addAttribute(
                \Magento\Catalog\Model\Product::ENTITY,
                'is_featured',
                [
                    'group' => 'General',
                    'type' => 'int',
                    'backend' => '',
                    'frontend' => '',
                    'label' => 'Is Featured',
                    'input' => 'boolean',
                    'class' => '',
                    'source' => 'Magento\Eav\Model\Entity\Attribute\Source\Boolean',
                    'global' => \Magento\Eav\Model\Entity\Attribute\ScopedAttributeInterface::SCOPE_GLOBAL,
                    'visible' => true,
                    'required' => false,
                    'user_defined' => false,
                    'default' => '1',
                    'searchable' => false,
                    'filterable' => false,
                    'comparable' => false,
                    'visible_on_front' => false,
                    'used_in_product_listing' => false,
                    'unique' => false,
                    'apply_to' => ''
                ]
            );

 

Is that I need in my module?
Create all fields in this way?


1.pngI want to do this!

Re: Custom module multistore language

Hi @Peleja,

 

Well... you have 3 optiosn to build a module that stores information into the database.

 

First option is a flat table module (like the tutorial show shared). In that case you have one table and values are global. You can't assign different values per store view.

 

Second option is to use a flat table with store view support (like cms pages and cms blocks). In that case you have your original table and a second one to relate values ids with store views ids.

 

Third option is the more advanced and powerfull: an entity with eav attributes.

 

I guess the best approach for you could be the second one. Magento_Cms module could help you to understand that kind of approach.

Re: Custom module multistore language

How i can do this?

 

First option is a flat table module (like the tutorial show shared). In that case you have one table and values are global. You can't assign different values per store view.

Re: Custom module multistore language

Hi @Peleja,


Take a look into the Magento_Cms module. You can see how blocks handle the multi-store values.