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

#   VM Import - Import of products images is broken

##

- **[korzo](/forum/user/34428-korzo "View korzo's Profile")**
- [![korzo's Avatar](https://www.hikashop.com/media/kunena/avatars/resized/size144/users/avatar34428.png)](/forum/user/34428-korzo "View korzo's Profile") Topic Author
- [ Offline](/forum/user/34428-korzo)

Less More

- Posts: 193
- Thank you received: 76
-
-

11 years 10 months ago [\#184933](#184933) by [korzo](/forum/user/34428-korzo "View korzo's Profile")  *[VM Import - Import of products images is broken](/forum/3-bug-report/873941-vm-import-import-of-products-images-is-broken#184933 "-- HikaShop version -- : 2.3.5 -- Joomla version -- : 3.3.6  Version 2.3.5 introduced 2 new bugs in import from Virtuemart.  1. no image is assigned to product as column file&#95;path in table #&#95;&#95;rbl&#95;hikashop&#95;file is NULL for all records from this table. 2. massive number of duplicated records in table #&#95;&#95;rbl&#95;hikashop&#95;file. There is 111506 records for 4552 images from VM. Screenshot of distinct values attached.")* was created by *[korzo](/forum/user/34428-korzo "View korzo's Profile")*

-- HikaShop version -- : 2.3.5
-- Joomla version -- : 3.3.6

Version 2.3.5 introduced 2 new bugs in import from Virtuemart.

1. no image is assigned to product as column file_path in table #__rbl_hikashop_file is NULL for all records from this table.
2. massive number of duplicated records in table #__rbl_hikashop_file. There is 111506 records for 4552 images from VM.
Screenshot of distinct values attached.

- [ ![hikashop&#95;file.jpg](/forum/attachment/21413) ](/forum/attachment/21413 "hikashop&#95;file.jpg") [ ](/forum/attachment/21413?download=1 "hikashop&#95;file.jpg")

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

- **[korzo](/forum/user/34428-korzo "View korzo's Profile")**
- [![korzo's Avatar](https://www.hikashop.com/media/kunena/avatars/resized/size144/users/avatar34428.png)](/forum/user/34428-korzo "View korzo's Profile") Topic Author
- [ Offline](/forum/user/34428-korzo)

Less More

- Posts: 193
- Thank you received: 76
-
-

11 years 10 months ago [\#184970](#184970) by [korzo](/forum/user/34428-korzo "View korzo's Profile")  Replied by *[korzo](/forum/user/34428-korzo "View korzo's Profile")* on topic *[VM Import - Import of products images is broken](/forum/3-bug-report/873941-vm-import-import-of-products-images-is-broken#184970 "-- HikaShop version -- : 2.3.5 -- Joomla version -- : 3.3.6  Version 2.3.5 introduced 2 new bugs in import from Virtuemart.  1. no image is assigned to product as column file&#95;path in table #&#95;&#95;rbl&#95;hikashop&#95;file is NULL for all records from this table. 2. massive number of duplicated records in table #&#95;&#95;rbl&#95;hikashop&#95;file. There is 111506 records for 4552 images from VM. Screenshot of distinct values attached.")*

I was wrong. It's broken since Hikashop 2.3.3(oldest version I have), but it worked partially and duplication of rows was much lower.

In 2.3.3 column **\#\_\_virtuemart\_medias.file\_title**  were used to identify product's image.
It worked partially for first product's image as long as user didn't change title of image.
By default title of first product's image is file name.

In 2.3.4 it was changed and main column to identify product's image is **\#\_\_virtuemart\_medias.file\_meta** and this exposed the bug as file_meta (alt for image) is empty by default.

At first, because of limit in SQL query on line [ 1254](https://gist.github.com/korzo/d4f5e44fc3e745e4f7c8#file-importvm-php-L1254), not all images are copied and referenced in $meta_files array.

Next because condition at lines [ 1280-1283](https://gist.github.com/korzo/d4f5e44fc3e745e4f7c8#file-importvm-php-L1280-L1283) is flawed, $meta_files is always empty.
It should be replaced with: Code:

$meta_files[] = $this-&gt;db-&gt;Quote($file_name);

The line [ 1348 ](https://gist.github.com/korzo/d4f5e44fc3e745e4f7c8#file-importvm-php-L1348) is where bug #1 come from.
Because vmm.file_meta and $meta_files are always empty, empty value is inserted in column #__hikashop_file.file_path for every row.

Duplication of rows come from line [ 1358](https://gist.github.com/korzo/d4f5e44fc3e745e4f7c8#file-importvm-php-L1358) as it insert all images of not yet imported products.

Method importDownloads() is also flawed.

Because of missing file_url column in select on line 1999, no file is copied, otherwise all images will be copied to "uploadsecurefolder" as in Hikashop 2.3.3.
Also column #___virtuemart_medias.file_is_product_image is not used in VM and instead there should be &#96;file_is_downloadable&#96;

Here is fixed SQL query on lines [ 1999-2004](https://gist.github.com/korzo/d4f5e44fc3e745e4f7c8#file-importvm-php-L1999-L2004)
Code:

$sql = 'SELECT vmm.virtuemart_media_id,vmm.file_meta,vmm.vmm.file_meta,vmm.file_is_downloadable '. 'FROM &#96;'.$this-&gt;vmprefix.'virtuemart_products&#96; vmp ' . "INNER JOIN &#96;".$this-&gt;vmprefix."virtuemart_product_medias&#96; AS vmpm ON vmp.virtuemart_product_id = vmpm.virtuemart_product_id " . "INNER JOIN &#96;".$this-&gt;vmprefix."virtuemart_medias&#96; vmm ON vmpm.virtuemart_media_id = vmm.virtuemart_media_id " . 'WHERE vmm.virtuemart_media_id &gt; '.$offset. ' AND vmm.file_is_downloadable = 1'. ' ORDER BY vmm.virtuemart_media_id ASC LIMIT '.$count.';';

Here is fied code from lines 2067-2079 Code:

$data = array( 'file_name' =&gt; 'vmm.file_title', 'file_description' =&gt; 'vmm.file_description', 'file_path' =&gt; "SUBSTRING_INDEX(SUBSTRING_INDEX(vmm.file_url, '/', -1), '\\\\', -1)", 'file_type' =&gt; "'file'", 'file_ref_id' =&gt; 'hkp.hk_id' ); $sql = 'INSERT IGNORE INTO &#96;#__hikashop_file&#96; (&#96;'.implode('&#96;,&#96;',array_keys($data)).'&#96;) '. 'SELECT '.implode(',',$data).' FROM &#96;'.$this-&gt;vmprefix.'virtuemart_products&#96; vmp '. "INNER JOIN &#96;".$this-&gt;vmprefix."virtuemart_product_medias&#96; AS vmpm ON vmp.virtuemart_product_id = vmpm.virtuemart_product_id ". "INNER JOIN &#96;".$this-&gt;vmprefix."virtuemart_medias&#96; vmm ON vmpm.virtuemart_media_id = vmm.virtuemart_media_id " . 'INNER JOIN &#96;#__hikashop_vm_prod&#96; AS hkp ON vmm.virtuemart_media_id = hkp.vm_id '. 'WHERE vmm.virtuemart_media_id &gt; '.$this-&gt;options-&gt;last_vm_pfile. ' AND vmm.file_is_downloadable = 1'.';';

Anyway method importDownloads() will also suffer the row duplication and missing records as importProducts().

I was trying to fix it, but because of lack of time I had to comment it out and run queries and copy files by hand.

Hope it helps.

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

- **[Jerome](/forum/user/80-jerome "View Jerome's Profile")**
- [![Jerome's Avatar](https://www.hikashop.com/media/kunena/avatars/resized/size144/users/avatar80.png)](/forum/user/80-jerome "View Jerome's Profile")
- [ Offline](/forum/user/80-jerome)
- HikaShop core developer

Less More

- Posts: 26401
- Thank you received: 4080
-
- [](http://obsi.dev)
-

11 years 8 months ago [\#191628](#191628) by [Jerome](/forum/user/80-jerome "View Jerome's Profile")  Replied by *[Jerome](/forum/user/80-jerome "View Jerome's Profile")* on topic *[VM Import - Import of products images is broken](/forum/3-bug-report/873941-vm-import-import-of-products-images-is-broken#191628 "-- HikaShop version -- : 2.3.5 -- Joomla version -- : 3.3.6  Version 2.3.5 introduced 2 new bugs in import from Virtuemart.  1. no image is assigned to product as column file&#95;path in table #&#95;&#95;rbl&#95;hikashop&#95;file is NULL for all records from this table. 2. massive number of duplicated records in table #&#95;&#95;rbl&#95;hikashop&#95;file. There is 111506 records for 4552 images from VM. Screenshot of distinct values attached.")*

Hi,

We made few modifications in the VM import system for the next release.
We will see if we can improve more the import of the images to handle the different cases of VM2 (which change between versions and we have to handle them all...)
I test your patches but they didn't work good on my VM2 test store so I can't keep them ; but thanks for the report, we will continue to improve the VM import (I started a split in the import in order to have one import for VM1 and another for VM2 ; it will be easier to maintain).

Regards,

---

Jerome - Obsidev.com
HikaMarket &amp; HikaSerial developer / HikaShop core dev team.

Please [Log in](/login?return=aHR0cHM6Ly93d3cuaGlrYXNob3AuY29tL2ZvcnVtLzMtYnVnLXJlcG9ydC84NzM5NDEtdm0taW1wb3J0LWltcG9ydC1vZi1wcm9kdWN0cy1pbWFnZXMtaXMtYnJva2VuP3RtcGw9bWFya2Rvd24=) 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.068 seconds

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