Jump to content

Afficher les attachements d'un produit dans order-details


Recommended Posts

Bonjour,

 

Dans le cadre d'un soucis technique j'ai besoin d'afficher les fichiers joints d'un produit x/y lors du détail de la commande. Soucis que je recontre actuellement c'est qu'en essayant diverses manipulation ces dernières sont retées sans succès, je suis sous prestashop 1.6.9

 

Mes derniers essais:

Rajout ligne 180 OrderdetailController:

 

 

'attachments' => (($this->product->cache_has_attachments) ? $this->product->getAttachments($this->context->language->id) : array()),

 

Rajout ligne 410 Orderdetail:

 

    public static function updateCacheAttachment($id_product)
    {
        $value = (bool)Db::getInstance()->getValue('
                                SELECT id_attachment
                                FROM '._DB_PREFIX_.'product_attachment
                                WHERE id_product='.(int)$id_product);
        return Db::getInstance()->update(
                        'product',
                        array('cache_has_attachments' => (int)$value),
                        'id_product = '.(int)$id_product
                    );
    }    
    
    /**
    * Delete product attachments
    *
    * @param boolean $update_cache If set to true attachment cache will be updated
    * @return array Deletion result
    */
    public function deleteAttachments($update_attachment_cache = true)
    {
        $res = Db::getInstance()->execute('
            DELETE FROM `'._DB_PREFIX_.'product_attachment`
            WHERE `id_product` = '.(int)$this->id
        );
        
        if (isset($update_attachment_cache) && (bool)$update_attachment_cache === true)
            Product::updateCacheAttachment((int)$this->id);

        return $res;
    }

 

Rajout 561 order-detail.tpl

 

            <!--Download -->
            <section class="page-product-box">
                <h3 class="page-product-heading">{l s='Download'}</h3>
                {foreach from=$attachments item=attachment name=attachements}
                    {if $smarty.foreach.attachements.iteration %3 == 1}<div class="row">{/if}
                        <div class="col-lg-4">
                            <h4><a href="{$link->getPageLink('attachment', true, NULL, "id_attachment={$attachment.id_attachment}")|escape:'html':'UTF-8'}">{$attachment.name|escape:'html':'UTF-8'}</a></h4>
                            <p class="text-muted">{$attachment.description|escape:'html':'UTF-8'}</p>
                            <a class="btn btn-default btn-block" href="{$link->getPageLink('attachment', true, NULL, "id_attachment={$attachment.id_attachment}")|escape:'html':'UTF-8'}">
                                <i class="icon-download"></i>
                                {l s="Download"} ({Tools::formatBytes($attachment.file_size, 2)})
                            </a>
                            <hr>
                        </div>
                    {if $smarty.foreach.attachements.iteration %3 == 0 || $smarty.foreach.attachements.last}</div>{/if}
                {/foreach}
            </section>
            <!--end Download -->

 

 

Donc en gros actuellement je voit affiché download (même pas traduit au passage) et rien de plus. Je ne sais plus trop ou chercher et commece à me perdre la dedans ^^

Si quelqu'un voulait bien m'apporter son aide ou une indication je suis preneur car actuellement $attachment.name je donne strictement rien.

 

Merci d'avance.

Cordialement,

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