src/Object/Product/Product.php
private function altImagesToUnique()
    {
        if ($this->alternateImageUrls->count() === 0) {
            return;
        }
        $images = $this->getAlternateImageUrls();
        $resetImages = false;
        $duplicates = array_count_values($images);
        foreach ($duplicates as $val => $count) {
            if ($count > 1) {
                $resetImages = true;
                $images = array_unique($images);
                break;
            }
        }
        $key = array_search($this->getImageUrl(), $images, true);
        if ($key !== false) {
            $resetImages = true;
            unset($images[$key]);
        }
        if ($resetImages) {
            $this->setAlternateImageUrls(array_values($images));
        }
    }
private function altImagesToUnique()
    {
        if ($this->alternateImageUrls->count() === 0) {
            return;
        }
        $images = $this->getAlternateImageUrls();
        $resetImages = false;
        $duplicates = array_count_values($images);
        foreach ($duplicates as $val => $count) {
            if ($count > 1) {
                $resetImages = true;
                $images = array_unique($images);
                break;
            }
        }
        $key = array_search($this->getImageUrl(), $images, true);
        if ($key !== false) {
            $resetImages = true;
            unset($images[$key]);
        }
        if ($resetImages) {
            $this->setAlternateImageUrls(array_values($images));
        }
    }
private function altImagesToUnique ( ) { if ( $ this -> alternateImageUrls -> count ( ) === 0 ) { return ; } $ images = $ this -> getAlternateImageUrls ( ) ; $ resetImages = false ; $ duplicates = array_count_values ( $ images ) ; foreach ( $ duplicates as $ val => $ count ) { if ( $ count > 1 ) { $ resetImages = true ; $ images = array_unique ( $ images ) ; break ; } } $ key = array_search ( $ this -> getImageUrl ( ) , $ images , true ) ; if ( $ key !== false ) { $ resetImages = true ; unset ( $ images [ $ key ] ) ; } if ( $ resetImages ) { $ this -> setAlternateImageUrls ( array_values ( $ images ) ) ; } }
Makes the alternative images collection unique and removes
the main product image from alt images if present
Makes the alternative images collection unique and removes the main product image from alt images if present