Product variation images generating in XML file

This topic has 11 replies, 2 voices, and was last updated 2 years, 7 months ago ago by jim2sim

  • Avatar: jim2sim
    jim2sim
    Participant
    April 25, 2022 at 11:25

    Please read in private

    Please, contact administrator
    for this information.
    10 Answers
    Avatar: Olga Barlow
    Olga Barlow
    Support staff
    April 25, 2022 at 18:53

    Hello,

    Do you use our built-in variation gallery option or do you use a third-party variation gallery plugin?

    Regards

    Avatar: jim2sim
    jim2sim
    Participant
    April 25, 2022 at 19:44

    I use variation gallery from xstore. I mean default and no third-party.

    Avatar: Olga Barlow
    Olga Barlow
    Support staff
    April 26, 2022 at 14:13

    Hello,

    1) Provide us with WP Dashboard and FTP access to your site
    2) Tell me your actions to create XML file for the product that you use.
    We’ll try some code and need to check if that works in your case.
    3) Provide us with link to the variable product that comes with the variation gallery.

    Regards

    Avatar: jim2sim
    jim2sim
    Participant
    April 26, 2022 at 14:22

    Please change only the custom field what you use on this code.
    And i go to add to function. View the code please in private.

    Please contact administrator
    for this information.
    Avatar: jim2sim
    jim2sim
    Participant
    April 26, 2022 at 14:44

    READ PRIVATE

    Please contact administrator
    for this information.
    Avatar: Olga Barlow
    Olga Barlow
    Support staff
    April 27, 2022 at 09:43

    Hello,

    Thank you. I passed the issue to our developers. I’ll inform you once get the answer from them.

    Regards

    Avatar: jim2sim
    jim2sim
    Participant
    April 28, 2022 at 12:09

    READ

    Please contact administrator
    for this information.
    Avatar: Olga Barlow
    Olga Barlow
    Support staff
    April 28, 2022 at 18:30

    Hello,

    Sorry for the delay, we have a lot of requests. But I’ll try to speed up the process.

    Regards

    Avatar: Olga Barlow
    Olga Barlow
    Support staff
    April 29, 2022 at 09:01

    Hello,

    Thank you for your patience.
    Our developers took a look at the issue and found the following:

    Plugin author uses $product->get_image_id() in his code but he should use $attachment_id
    https://prnt.sc/bwkqupWZJkZe

    It took the main image for each variation gallery image before https://prnt.sc/utcZh4ZSq_f-
    after the global plugin code fix, it took the correct images
    https://prnt.sc/Bed1dsuAntsi

    Code before

    public function get_gallery($product) {
            $attachment_ids = apply_filters('webexpert_skroutz_xml_custom_gallery', $product->get_gallery_image_ids(), $product);
            if (sizeof($attachment_ids)>0) {
                foreach ($attachment_ids as $attachment_id) {
                    $this->xml->startElement('additional_imageurl');
                    $this->xml->writeCData(esc_html(apply_filters('webexpert_skroutz_xml_custom_image',wp_get_attachment_url($product->get_image_id()),$product)));
                    $this->xml->endElement();
                }
            }
        }
    

    After

    public function get_gallery($product) {
            $attachment_ids = apply_filters('webexpert_skroutz_xml_custom_gallery', $product->get_gallery_image_ids(), $product);
            if (sizeof($attachment_ids)>0) {
                foreach ($attachment_ids as $attachment_id) {
                    $this->xml->startElement('additional_imageurl');
                    $this->xml->writeCData(esc_html(apply_filters('webexpert_skroutz_xml_custom_image',wp_get_attachment_url($attachment_id),$product)));
                    $this->xml->endElement();
                }
            }
        }
    

    We added fix on your website globally in
    plugins/webexpert-skroutz-xml-feed/includes/scripts/skroutz-engine-v3.php. Contact plugin author and ask them to fix the code because you will lose this fix after plugin update if they don’t fix it globally.

    And we added custom filter in xstore-child/functions.php in addition

    add_filter('webexpert_skroutz_xml_custom_gallery','webexpert_skroutz_xml_custom_gallery_custom',20,2);

    function webexpert_skroutz_xml_custom_gallery_custom($gallery_image_ids,$product) {
    	if ( $product->is_type( 'variation' ) ) {
    		$has_variation_gallery_images = (bool) get_post_meta( $product->get_id(), 'et_variation_gallery_images', true );
    		if ( $has_variation_gallery_images ) {
    			$gallery_images = (array) get_post_meta( $product->get_id(), 'et_variation_gallery_images', true );
    			return $gallery_images;
    		}
            return $gallery_image_ids;
    	}
    	return $gallery_image_ids;
    }

    Regards

    Avatar: jim2sim
    jim2sim
    Participant
    April 29, 2022 at 14:37

    Thank you.

  • Viewing 11 results - 1 through 11 (of 11 total)

The issue related to '‘Product variation images generating in XML file’' has been successfully resolved, and the topic is now closed for further responses

We're using our own and third-party cookies to improve your experience and our website. Keep on browsing to accept our cookie policy.