Trouble downloading XML and images

Closed
ImportWP Pro - WordPress XML & CSV Importer ImportWP Pro - WordPress XML & CSV Importer January 18, 2019
Login to reply
James Collings Support Agent
4 months ago

Ticket Closed due to no Response from customer

James Collings Support Agent
4 months ago

Thanks chris,

i have only setup the new download permissions to work with the custom fields, so to get around this (sorry your screenshot didnt upload so cant see what you had setup) but if you clear your settings from the attachment tab and instead make a new custom field with the Enable text field checked and the name _thumbnail_id , as shown in the attached screenshot.

This will use the same download checks and should not download duplicates.

Chris Creswick
4 months ago

Hi james,

The majority of them say updated but some do say inserted. I have checked both types though and the images are still being downloaded for all and the latest download is being used in the post.

Ive attached the atachment settings screenshot.

I only use this to get the feature image

James Collings Support Agent
4 months ago

Can you check a few things for me:

If you go into the importer  > History tab and view the latest import, does the method say Inserted or Updated

Do you have anything setup in the Attachments tab of the importer?

Cheers

Chris Creswick commented privately
James Collings Support Agent
4 months ago

Hi Chris,

Are you able to send me a screenshot of the settings you have for your image imports, and possibly a small section of the file you are trying to import where the images are being re-downloaded each time.

James

Chris Creswick commented privately
James Collings Support Agent
4 months ago
Resolved.
James Collings Support Agent commented privately
James Collings Support Agent
5 months ago

Hi Chris,

If you update the plugin it will wipe stop the extra acf data being added for that gallery field. To stop this i will add in some hooks into the plugin before the next major release (will give you a heads up and will need to adapt your current fix to work with this new method), this way future updates will work seamlessly.

James

Chris Creswick
5 months ago

Hi James,

I have installed a media cleaner and it seems to be working for now and I think we have the issues sorted now.

With you making changes to the plugin, will it still work correctly when I update the plugin?

Chris

James Collings Support Agent
5 months ago

Currently the importer keeps track of records that have been imported such as posts, taxonomies and users, but not of the related media such as images and files.

This is due it not knowing if media has been used elsewhere in the website and if it was to be deleted it would could break other parts of the site which you wouldn't want happening.

If you want to remove the extra images i would recommend looking for a media cleaning plugin or something like that can remove these, maybe try looking https://wordpress.org/plugins

James

Chris Creswick
5 months ago

Hi james,

I have inserted a new gallery type and for now it seems to be working.

The importer however does not delete the images when it is rerun, it imports the images as brand new ones and leaves the old images there. Over the last few days with the imports this has risen to nearly 200k images. Isnt the importer supposed to remove the images when it updates the post?


Chris

James Collings Support Agent
5 months ago

Cheers, looks like with ACF you also need to store a custom meta field called _gallery with the field id that acf uses to display.

I have ran a section of the import to test, a preview of an item with this new meta field in place seems to work: http://homestylegb.com/furniture/3-x-2-z-coffee-table/

I have modified your importer to automatically add in that meta field for the gallery field, if you can re run the import it should display correctly.

Chris Creswick
5 months ago

HI,

Printing them returns the following arrays

Array ( [0] => 11772 [1] => 11773 )

James Collings Support Agent
5 months ago

if you print_r($images) do you get a list of id's or a list of acf image arrays?

Chris Creswick
5 months ago
It was working before
Chris Creswick
5 months ago
$images = get_field('gallery');if( $images ): ?>    <ul>      <?php foreach( $images as $image ): ?>            <li>                <a href="<?php echo $image['url']; ?>">                     <img src="<?php echo $image['sizes']['thumbnail']; ?>" alt="<?php echo $image['alt']; ?>" />                </a>                <p><?php echo $image['caption']; ?></p>            </li>        <?php endforeach; ?>    </ul><?php endif; ?>
James Collings Support Agent
5 months ago

What php code have you used to display gallery field?

Chris Creswick
5 months ago

Hi James,


I have removed all the furntiture and tried the import again and this time it is pulling the images in however something has happened to the image source. 

I had the g allery fields setup to displau thumbnails of the additional images but now it just lists a bullet point and a link. please see this product: http://homestylegb.com/furniture/3-x-2-z-coffee-table/

Thanks

James Collings Support Agent
5 months ago

Hi Chris,

Have you tried deleting all furniture items before running the import?

James

Chris Creswick
5 months ago

Hi James,

I have ran the importer you created and it is not pulling the images in, it works for the first product in the feed but not for any after that.

I have set rows to 0 so that it gets everything and there are no errors on the import, just hasnt worked.

Chris

James Collings Support Agent
5 months ago

Hi Chris,

I have added in a work around specifc for your import just now for when you are importing into the gallery field, for some reason your version of acf is not liking the images being stores as a csv list of attachment ids e.g. 1,2,3 but instead i had to serialize the data, at the moment ImportWP imports custom fields, but i havent tried to do full integration with the acf plugin, i will look into this and see if i can support the acf plugin in future as it is popular.

I would recommend clearing out all your previous furniture items if you can and run the importer with the JC prefix in the title, i have tested this with one furniture item and it has imported the first image as featured, and inserted all the images into the gallery field.

James

Chris Creswick
5 months ago

Hi James,

I have reactivated the ACF pro plugin.

Let me know how you get on.

Chris

James Collings Support Agent
5 months ago

Hi Chris,

I have had a look into this but i have managed to get ACF Pro deactivated on your plugins page, with know way to reactivate it (i was trying to disable acf but keep acf pro active to see if this was causing issues having both running).

If you can let me know when you have this plugin reactivated that would be great so i can look into this further.

James

Chris Creswick
5 months ago

Hello James,

Sorry i did not reply sooner, I have been away for a while on business.

I have applied the changes you listed below and now the image does get inserted into the gallery field. It only pulls the first image however and does not pull any other images.

I have tried importing using the nodes separated by commas and using without nodes but it will not pull any extra images in.

The login details I provided you with earlier in this post still work so you can see that I have followed your settings.

Any assistance would be greatly appreciated.

Chris

James Collings Support Agent
6 months ago
Resolved.
James Collings Support Agent
6 months ago

Using your previus XML, i have tested this when there are multiple "images" notes, if you select the name of the acf gallery field from the dropdown from the list of fields.

if you want control over what images are imported for the field you can set the value by seperating the values with a comma as such:

{/images[1]},{/images[2]},{/images[3]}

Or you can fetch all images nodes by setting the value of (removing the node index):

{/images}

To complete the ACF gallery setup you need to make sure you have the following:

Field Type: Attachment
Value: Comma seperated values
Return Value: ID
Download: Remote URL

James Collings Support Agent
6 months ago

Hi Chris,

ImportWP Pro allows you to import to wordpress custom fields in general, and has some basic Integration with the core ACF plugins fields,  if you can let me know what version of ACF / ACF Pro Are you using i can have a look into this and see what settings are needed or if i need to add in some extra functionality.

Chris Creswick
6 months ago

Hi James,

Hope you are well, I have been testing the import the last couple for days and things are going well. 

I am now trying to import multiple images as we discussed before but I am hitting a wall.  I am using the settings that you sent but it does not pull the images in, I think it may be due to me using the Gallery addon to the ACF plugin.

Is there a different method for the settings when using ACF Gallery?

Chris

Chris Creswick
6 months ago

Hi,

I have just ran an import on the whole remote file and this time it has worked. 

I suppose the main concern is stability...

I will run tests over the next few hours and let you know if i get any issues.

Chris

James Collings Support Agent
6 months ago

Updated and tested, should be working now

Chris Creswick commented privately
James Collings Support Agent commented privately
Chris Creswick commented privately
James Collings Support Agent
6 months ago

You dont need the custom field it was just an example or different ways to attach images.

Chris Creswick
6 months ago

Hi James,


I have tried your solution with the attachment field and it is working now, I will quest that the xml be adjusted to remove the white space.

Can I ask, does the custom fields settings have to be put in as well as the attachment or can they be done separately?

Chris

James Collings Support Agent commented privately
Chris Creswick
6 months ago

Hi James,

I assumed the cdata was the issue so I have tried witout wrapping the image and it gives the same result.

Instances where there are more images, the field just repeats itself like below:

<images>

<![CDATA[

http://homestylegb.com/wp-content/uploads/2019/01/cat-bedroom.jpg

]]>

</images>

<images>

<![CDATA[

http://homestylegb.com/wp-content/uploads/2019/01/cat-bedroom.jpg

]]>

</images>

<images>

<![CDATA[

http://homestylegb.com/wp-content/uploads/2019/01/cat-bedroom.jpg

]]>

</images>

James Collings Support Agent
6 months ago
Do you have an example of when there are more than 1 image?
James Collings Support Agent
6 months ago

Thanks for sending over the xml, i have an idea of what it could be the CDATA tags wrapping the image, i will test this out and get back to you.


Chris Creswick commented privately
Chris Creswick commented privately
James Collings Support Agent commented privately
Chris Creswick
7 months ago

Hello,


The xml file download is no longer an issue as the developers of the API have created an XML download for me so is fine now.


The main issue I am having is getting images to import. The feed I am using imports 1-4 images per entry so I must have this working.


Debug info below:


WordPress version: 5.0.3

Plugin version: 1.0.5

Php version: 7.0.33

Max execution time: 30

Max input time: 60

Memory Limit: 256M

DISABLE_WP_CRON: No

Toggle panel: File Upload

Post max size: 8M

Upload max filesize: 20M

Remote Fetch: Curl Request

Temp directory: /home/homestyle/public_html/wp-content/uploads/importwp

Temp directory writable: Yes

Toggle panel: Cron

Php version: 5.6.39

Max execution time: 0

Max input time: 60

Memory Limit: 256M

Post Max Size: 24M

Upload Max Filesize: 10M

Remote Fetch: Curl Request

Temp directory: /home/trojan1988/public_html/homestyle/wp-content/uploads/importwp

Temp directory writable: Yes


James Collings Support Agent
7 months ago

Hi Chris,

Are you able to get some debug info via ImportWP > Settings > Debug and copy all the information.

Not being able to download an xml file from that url initialy made me think there might be something wrong with the xml files mime type, are you able to download the file and send me a copy? if not can you download it and add it to an importer manually, does this work?

But since you are also not able to download attachments via custom fields / or by attachment, this points towards the method of fetching the file, hopefully the debug information.

Thanks

James

Chris Creswick
7 months ago

Hi,

I am having trouble downloading an XMl file, the api uses a token which amends the url of the file. For example: https://test.url/api/supplier/products?token=QPohB3N50ipnnuymhEFy&format=xml&page=1&page_size=5000

When I try to download this file your plugin fails because it cannot determine the file type. Can you assist me in finding a solution to this?

Secondly, your plugin will not download images into my custom post type. I have tried custom fields and attachment/set featured image options. The importer says complete with 0 errors but the image are not downloaded and placed in post.

Thanks