Jump to content
thirty bees forum
  • 0

Attachments not visible in product backoffice


Question

Posted

When i go to backoffice in Thirtybees 1.0.3 and upload an attachment in "Catalog - Attachments", i am not able to find the uploaded attachment when i go to a product and would like to choose the recent uploaded attachment.

If i dublicate a product with an attachment, the attachment disappears on the new product. If i try to upload the attachment manually in each product, it works fine.

0_1509091550039_Print screen.png

Problem solved 02.01.2018 by following @SLiCK_303's suggestion by replacing the code below in "Classes/Attachment.php"

Replace:

public static function getAttachments($idLang, $idProduct, $include = true)
{
    return Db::getInstance(_PS_USE_SQL_SLAVE_)->executeS(
        (new DbQuery())
            ->select('a.*, al.*')
            ->from('attachment', 'a')
            ->leftJoin('attachment_lang', 'al', 'a.`id_attachment` = al.`id_attachment`')
            ->leftJoin('product_attachment', 'pa', 'pa.`id_attachment` = a.`id_attachment`')
            ->where('al.`id_lang` = '.(int) $idLang)
            ->where($include ? 'pa.`id_product` = '.(int) $idProduct : '')
            ->where('pa.`id_product` IS '.($include ? 'NOT ' : '').'NULL')
    );
}

with:

public static function getAttachments($idLang, $idProduct, $include = true)
{
    return Db::getInstance()->executeS('
        SELECT *
        FROM '._DB_PREFIX_.'attachment a
        LEFT JOIN '._DB_PREFIX_.'attachment_lang al
            ON (a.id_attachment = al.id_attachment AND al.id_lang = '.(int) $idLang.')
        WHERE a.id_attachment '.($include ? 'IN' : 'NOT IN').' (
            SELECT pa.id_attachment
            FROM '._DB_PREFIX_.'product_attachment pa
            WHERE id_product = '.(int) $idProduct.'
        )'
    );
}

15 answers to this question

Recommended Posts

  • 0
Posted

Yes dublicates loses the attachments but the main problem is that attachments uploaded in "Catalog - Attachments" can't be chosen afterwards in the products, which is a problem if you would like to use the same attachment for several products.

The print screen in the top is an example of how it looks when i edit a product and would like to choose an attachment i already have uploaded, then i can't find the attachment.

  • 0
Posted

Hi, Is there any progress on this "Attachments not visible in product backoffice" issue? Or is there a workround/permissions thing I can use? This is a pretty serious issue for me. I have been using Prestashop on projects until now but don't like the way things are going. so I thought I would try 30b... This problem is the only issue that has affected me so far and it affects us pretty seriously.

  • 0
Posted

Works fine for me, in both 1.0.3 and in 1.0.4. Except for when you duplicate the product, then the attachment doesn't come along, but then again neither do specific prices so......

  • 0
Posted

The issue I see has to do with /classes/Attachment.php. If I take the one outta ps1.6.1.17, it lets me pick the same attachment for any/all products. As I'm not sure the ramifications of swapping out that file, I don't recommend this as a fix, but rather a starting point to troubleshoot the issue.

  • 0
Posted

Thanks for the responses and i am sorry if I was not as detailed as I could have been. To reproduce: 1. Create an attachment document using: Catalog ->Attachments -> Add new attachment 2. Create a new product using: Catalog -> Products -> Add new product 3. Save the product 4. Attach the document created in step 1 above

My Outcome: The attachment created in step 1 is not visible and so cannot be attached Sometimes it is visible for the first product created but not for any subsequent products

Thanks

  • 0
Posted

replace.. public static function getAttachments($idLang, $idProduct, $include = true) { return Db::getInstance(_PS_USE_SQL_SLAVE_)->executeS( (new DbQuery()) ->select('a.*, al.*') ->from('attachment', 'a') ->leftJoin('attachment_lang', 'al', 'a.`id_attachment` = al.`id_attachment`') ->leftJoin('product_attachment', 'pa', 'pa.`id_attachment` = a.`id_attachment`') ->where('al.`id_lang` = '.(int) $idLang) ->where($include ? 'pa.`id_product` = '.(int) $idProduct : '') ->where('pa.`id_product` IS '.($include ? 'NOT ' : '').'NULL') ); }

with.. public static function getAttachments($idLang, $idProduct, $include = true) { return Db::getInstance()->executeS(' SELECT * FROM '._DB_PREFIX_.'attachment a LEFT JOIN '._DB_PREFIX_.'attachment_lang al ON (a.id_attachment = al.id_attachment AND al.id_lang = '.(int) $idLang.') WHERE a.id_attachment '.($include ? 'IN' : 'NOT IN').' ( SELECT pa.id_attachment FROM '._DB_PREFIX_.'product_attachment pa WHERE id_product = '.(int) $idProduct.' )' ); }

If you didn't have those two files handy... edit: I modified the first two variables, just to make it more a little more current. It would be nice if it was re-written with the (new DbQuery()) type... hint hint, nudge nudge... ;)

  • 0
Posted

Thank you everyone,

I have replaced the public static function getAttachments (found in /classes/Attachment.php) with the function as suggested by SLiCK_303 and all is working perfectly.

For me this problem appears solved for the current version. I am guessing that this will be integrated into the development cycle for future versions. I have just checked the github version and it is still at the old version. I am not a code contributor so I cannot do this.

John

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