1

Please help, how will I get bundle parent id inside this block? also, I would like to get the parent product ID and one of the custom attribute label called "image_type"?

<?php
namespace Company\Tools\Block\Product\Bundle;

use Ewave\ExtendedBundleProduct\Block\Product\Bundle\Configurable as EwaveConfigurable;

/**
 * Class Configurable
 * @package Company\Tools\Block\Product\Bundle
 */
class Configurable extends EwaveConfigurable
{
    /**
     * Get product images for configurable variations
     *
     * @return array
     * @since 100.1.10
     */



protected function getOptionImages()
    {


        $images = [];
        foreach ($this->getAllowProducts() as $product) {
            $productImages = $this->helper->getGalleryImages($product) ?: [];
            foreach ($productImages as $image) {
                $images[$product->getId()][] =
                    [
                        'thumb' => $image->getData('small_image_url'),
                        'img' => $image->getData('medium_image_url'),
                        'full' => $image->getData('large_image_url'),
                        'caption' => $image->getLabel(),
                        'position' => $image->getPosition(),
                        'isMain' => $image->getFile() == $product->getImage(),
                        'type' => str_replace('external-', '', $image->getMediaType()),
                        'videoUrl' => $image->getVideoUrl(),
                        'swatch' => $this->_urlBuilder->getBaseUrl(['_type' => \Magento\Framework\UrlInterface::URL_TYPE_MEDIA])
                            . 'catalog/product'
                            . $product->getSwatchImage(),
                    ];
            }
        }

        return $images;
    }
}

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.