[Skip to main content](#vessel-content)

#   Show pruduct and variant files

##

- **[pljuarez](/forum/user/34788-pljuarez "View pljuarez's Profile")**
- [![pljuarez's Avatar](https://www.hikashop.com/media/kunena/core/svg/person.svg)](/forum/user/34788-pljuarez "View pljuarez's Profile") Topic Author
- [ Offline](/forum/user/34788-pljuarez)

Less More

- Posts: 79
- Thank you received: 3
-
-

11 years 1 week ago -  11 years 1 week ago [\#219431](#219431) by [pljuarez](/forum/user/34788-pljuarez "View pljuarez's Profile")  *[Show pruduct and variant files](/forum/31-development/880254-show-pruduct-and-variant-files#219431 "-- HikaShop version -- : Business: 2.6.0 -- Joomla version -- : 3.2.3 -- PHP version -- : 5.3.3  Hello, I write this entry because I found a problematic behavior when show product and variant files.  Some days ago, I had a problem to show product files in my site, this problem is solved (see ), but I think the behavior of &quot;show&quot; and &quot;show&#95;block&#95;product&#95;files views are a little strange.  Let see, when you have diferent files in main product, and in variants, only variant files are shown. If you have one common file for every variant (for example a book table of contents) and diferent files for variants (for example ebook file in differents formats). I think the logical behavior is &quot;I assign common file to main product and different ones to each variant&quot;. FAIL, this results in you only can see diferent ones assigned to each variant. You must assign all files to each variant, and if you have many common files and many variants this is a very tedious task.  The solution is to do a little change in &quot;show&quot; and &quot;show&#95;block&#95;product&#95;files views: in both views, change  With next code:  And a few lines down, you must duplicate the loop: In next manner:  I hope it has been useful to you.  Regards")* was created by *[pljuarez](/forum/user/34788-pljuarez "View pljuarez's Profile")*

-- HikaShop version -- : Business: 2.6.0
-- Joomla version -- : 3.2.3
-- PHP version -- : 5.3.3

Hello, I write this entry because I found a problematic behavior when show product and variant files.

Some days ago, I had a problem to show product files in my site, this problem is solved (see [ this entry for more information](http://www.hikashop.com/forum/product-category-display/880224-ghost-code-in-show-block-product-files-view.html)), but I think the behavior of *"show"* and *"show\_block\_product\_files* views are a little strange.

Let see, when you have diferent files in main product, and in variants, only variant files are shown.
If you have one common file for every variant (for example a book table of contents) and diferent files for variants (for example ebook file in differents formats). I think the logical behavior is "I assign common file to main product and different ones to each variant". FAIL, this results in you only can see diferent ones assigned to each variant. You must assign all files to each variant, and if you have many common files and many variants this is a very tedious task.

The solution is to do a little change in *"show"* and *"show\_block\_product\_files* views:
in both views, change Code:

if(!empty ($variant-&gt;files)) { $skip = true; foreach ($variant-&gt;files as $file) { if ($file-&gt;file_free_download) $skip = false; }

With next code: Code:

if(!empty ($variant-&gt;files) &#124;&#124; !empty ($this-&gt;element-&gt;main-&gt;files)); { $skip = true; foreach ($this-&gt;element-&gt;main-&gt;files as $mainfile){ if ($mainfile-&gt;file_free_download) $skip = false; } foreach ($variant-&gt;files as $file) { if ($file-&gt;file_free_download) $skip = false; }

And a few lines down, you must duplicate the loop: Code:

foreach ($variant-&gt;files as $file)

In next manner: Code:

foreach ($this-&gt;element-&gt;main-&gt;files as $mainfile) { if(empty ($mainfile-&gt;file_name)) { $mainfile-&gt;file_name = $mainfile-&gt;file_path; } $fileHtml = ''; if(!empty ($mainfile-&gt;file_free_download)) { $fileHtml = '&lt;a class="hikashop_product_file_link" href="' . hikashop_completeLink('product&amp;task=download&amp;file_id=' . $mainfile-&gt;file_id) . '"&gt;' . $mainfile-&gt;file_name . '&lt;/a&gt;&lt;br/&gt;'; } $html[] = $fileHtml; } foreach ($variant-&gt;files as $file) { ...

I hope it has been useful to you.

Regards

Last edit: 11 years 1 week ago by [pljuarez](/forum/user/34788-pljuarez "View pljuarez's Profile").

The following user(s) said Thank You: [nicolas](/forum/user/63-nicolas "View nicolas's Profile")

Please [Log in](/login?return=aHR0cHM6Ly93d3cuaGlrYXNob3AuY29tL2ZvcnVtLzMxLWRldmVsb3BtZW50Lzg4MDI1NC1zaG93LXBydWR1Y3QtYW5kLXZhcmlhbnQtZmlsZXM/dG1wbD1tYXJrZG93bg==) or [Create an account](/component/users/registration?Itemid=101) to join the conversation.

Board Categories HikaShop Install &amp; Update Product &amp; Category Display Content Creation Sales and Orders Orders management Reports &amp; Statistics Customers Checkout Payment Methods Shipping Methods Import &amp; Export (CSV, XLS…) Specific Features Affilation Taxes Wishlist Vote Carousel &amp; Slider Mass Actions Filters &amp; Search Discount &amp; Coupon Feature Request Integrations Showcase General Talk about HikaShop Development HikaShop 3.0 Beta Translation Commercial Jobs HikaShop Components HikaMarket Market: Feature requests Market: How to? Market: Bug Report HikaSerial General talk about HikaSerial Serial: Bug Report Serial: How to? Support en Français de HikaSerial (French Support) HikaSubscription HikaAuction Auction: Feature requests Auction: How to? Auction: Bug report Hikashop around the world Support en Français (French Support) Russian FAQ. Курс выживания с Hikashop. Частые вопросы и о Расширения Hikashop Наши сайты на Hikashop 日本語版サポート(Japanese Support) Thai German Archives Bug Report How to?

[](/forum/topics/feed/mode-topics?format=feed&type=rss)

Time to create page: 0.041 seconds

[Powered by](/forum/credits) [Kunena Forum](https://www.kunena.org)
