Jump to content

Edit Manufacturers Per Store - Multishop Issue


Recommended Posts

I have had one store running for about 6 months with no major issues.  I just changed it over to multistore and added a new domain.

 

Everything has been going wonderfully.....but I cannot customize my manufacturers on a PER SHOP level.  Every change I make effects both sites, even when I have single shop selected from the drop down.

 

In the Presta docs it says it can be done without issue.  St the bottom in the handy-dandy chart:  http://doc.prestashop.com/display/PS16/The+multistore+interface


So does anyone know what's up?  
 

Link to comment
Share on other sites

It seems that there is some issue when you are adding or editing manufacturers because PrestaShop is capable of handling manufacturers for multi-shops.

 

There are following three tables in the database to handle manufacturers in a PrestaShop store:

 

ps_manufacturer

ps_manufacturer_lang

ps_manufacturer_shop

 

The third table (i.e. ps_manufacturer_shop) saves the mapping for multiple shops. It might be possible that the manufacturer that you are editing is not mapped to your multiple shops.

 

You need to check this by checking the above tables for the manufacturer data that you are editing. You can also try after adding a new manufacturer into the system.

Link to comment
Share on other sites

Thanks!

 

Under manufacturer_shop it is creating two entries for the manufacturer.  One with id_shop=1 and another with id_shop=2.  That looks correct.

 

Under manufacturer_lang it is only creating one entry, all with id_lang=1.

 

I believe that under manufacturer_lang is should be creating two entries?  If so, do you know what might be causing this?  

Link to comment
Share on other sites

It seems you've found a bug in PrestaShop. The ps_manufacturer_lang and ps_supplier_lang tables should have an id_shop column like the ps_category_lang table.

 

You'll see in classes/Category.php the following line:

        'multilang_shop' => true,

This line is missing from classes/Manufacturer.php and classes/Supplier.php

  • Like 1
Link to comment
Share on other sites

I got very excited with such a small bug and easy fix....but just fixing the line doesn't appear to work.  I get an error message when I try to add/edit and of the manufacturers after correcting the code.

An error occurred while creating an object. manufacturer ()

Link to comment
Share on other sites

You'll need to add the id_shop column to the ps_manufacturer_lang table too. You can use a query like:
ALTER TABLE `ps_manufacturer_lang` ADD COLUMN `id_shop` int(10);
​UPDATE `ps_manufacturer_lang` SET `id_shop` = 1;

Change ps_ to your database prefix. You'll also need to change the primary key to include the `id_shop` column. Unfortunately, I don't know how to do that with an SQL query.

 

You can then copy the data to another shop using the query:

INSERT INTO `ps_manufacturer_lang` (`id_manufacturer`, `id_lang`, `description`, `short_description`, `meta_title`, `meta_keywords`, `meta_description`, `id_shop`)
SELECT `id_manufacturer`, `id_lang`, `description`, `short_description`, `meta_title`, `meta_keywords`, `meta_description`, 2
FROM `ps_manufacturer_lang`
​WHERE `id_shop` = 1

Change 1 to the source shop ID and 2 to the destination shop ID.

  • Like 1
Link to comment
Share on other sites

Thank you for walking me through that.  It all worked perfectly.  I'm fairly new with SQL so without your help I would have broken the DB more than once.


Now apparently my brands slider is throwing out duplicates so I will have to dig into that and figure that one out.

Almost there.....

 

Thank you again!

 

Link to comment
Share on other sites

You're welcome. :)

 

Look for code like this:

LEFT JOIN `'._DB_PREFIX_.'manufacturer_lang` ON (m.`id_manufacturer` = ml.`id_manufacturer)

and change it to something like this:

LEFT JOIN `'._DB_PREFIX_.'manufacturer_lang` ON (m.`id_manufacturer` = ml.`id_manufacturer AND ml.`id_shop` = '.(int)$this->context->shop->id.')

This should remove any duplicates caused by adding the id_shop column.

  • Like 1
Link to comment
Share on other sites

  • 1 month later...

rocky,

I'm sorry to bother you I've been testing this for over a week and haven't gotten it to function properly.  Mind taking a look at what I have?  Also - do you do custom work outside of your existing modules - I would love to have someone like you who is available for small contract work when I run into issues or need larger code changes...I've been on Volusion for ten years so this is taking a bit to get used to.  

 


{if $fieldbrandslider.manufacturers}
    <div id="fieldbrandslider" class="block horizontal_mode title_center">
        <div class="container">
                <div class="field-brand">
                    {if ($fieldbrandslider.mainTitle != '')}
                        <h4 class="title_block title_font"><a href="{$link->getPageLink('manufacturer')|escape:'html'}"><span class="title_text">{$fieldbrandslider.mainTitle}</span></a></h4>
                    {/if}
                     <div class="row">
                        <div id="fieldbrandslider-manufacturers" class="grid carousel-grid owl-carousel">
                            {foreach $fieldbrandslider.manufacturers as $manufacturer}
                                <div class="item">
                                    <a class="img-wrapper" href="{$link->getmanufacturerLink($manufacturer.id_manufacturer, $manufacturer.link_rewrite)|escape:'htmlall':'UTF-8'}" title="{$manufacturer.name|escape:'htmlall':'UTF-8'}">
                                        <img class="img-responsive" src="{$img_manu_dir}{$manufacturer.id_manufacturer|escape:'htmlall':'UTF-8'}-m_scene_default.jpg" width="{$manufactureSize.width}" height="{$manufactureSize.height}" alt="{$manufacturer.name|escape:'htmlall':'UTF-8'}" />
                                        {if isset($fieldbrandslider.mantitle) AND $fieldbrandslider.mantitle == 1}<br/>
                                            <p>{$manufacturer.name|escape:'htmlall':'UTF-8'}</p>
                                        {/if}
                                    </a>
                                </div>
                            {/foreach}
                        </div>
                </div>
        </div>
        </div>
    </div>
    {if ($fieldbrandslider.maxitem)}{addJsDef fieldbs_maxitem=$fieldbrandslider.maxitem}{else}{addJsDef fieldbs_maxitem=6}{/if}
    {if ($fieldbrandslider.minitem)}{addJsDef fieldbs_minitem=$fieldbrandslider.minitem}{else}{addJsDef fieldbs_minitem=2}{/if}
    {if ($fieldbrandslider.autoScroll)}{addJsDef fieldbs_autoscroll=$fieldbrandslider.autoScrollDelay}{else}{addJsDef fieldbs_autoscroll=false}{/if}
    {if ($fieldbrandslider.pauseOnHover)}{addJsDef fieldbs_pauseonhover=true}{else}{addJsDef fieldbs_pauseonhover=false}{/if}
    {if ($fieldbrandslider.pagination)}{addJsDef fieldbs_pagination=true}{else}{addJsDef fieldbs_pagination=false}{/if}
    {if ($fieldbrandslider.navigation)}{addJsDef fieldbs_navigation=true}{else}{addJsDef fieldbs_navigation=false}{/if}
{/if}
Link to comment
Share on other sites

Normally, I am available for paid work, but I've been unusually busy lately with the recent release of PrestaShop v1.7. I've been working on updating all my modules and improving my website.

 

I can't see anything obviously wrong with the code you've posted above.

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