getAttributes() as $a) { if (in_array($a->getName(), ['selected_image_urls', 'image_selection_confirmed', 'featured_image'], true)) { return $product; } } $images = array_values(array_filter($product->getImages(), static fn ($i): bool => ! self::isSiteAsset($i->getUrl()))); $changed = count($images) !== count($product->getImages()); $attributes = []; foreach ($product->getAttributes() as $a) { $value = $a->getValue(); if (in_array($a->getName(), ['cover_url', 'gallery_urls', 'available_image_urls'], true)) { $urls = preg_split('/[\r\n]+|,\s*(?=https?:\/\/)|\s+(?=https?:\/\/)/i', $value) ?: []; $value = implode(', ', array_values(array_filter(array_map('trim', $urls), static fn ($u): bool => $u !== '' && ! self::isSiteAsset($u)))); $changed = $changed || $value !== $a->getValue(); } $attributes[] = new AttributeDTO($a->getName(), $value, $a->getTaxonomy()); } if (! $changed) { return $product; } return new ProductDTO($product->getId(), $product->getName(), $product->getDescription(), $product->getShortDescription(), $product->getPrice(), $product->getInventory(), $product->getCategories(), $images, $attributes, $product->getSeo(), $product->getProviderInfo(), $product->getSku(), $product->getBarcode()); } }