Usunięcie sprawdzania duplikatów obrazów oraz poprawa logiki przypisywania obrazów do produktów
This commit is contained in:
@@ -123,9 +123,9 @@ function isImageAdded($productId, $imageUrl) {
|
||||
|
||||
// Function to download image from URL and associate it with a product
|
||||
function addProductImage($productId, $imageUrl) {
|
||||
if (isImageAdded($productId, $imageUrl)) {
|
||||
return false; // Skip duplicate images
|
||||
}
|
||||
// if (isImageAdded($productId, $imageUrl)) {
|
||||
// return false; // Skip duplicate images
|
||||
// }
|
||||
|
||||
$image = new Image();
|
||||
$image->id_product = $productId;
|
||||
@@ -311,7 +311,15 @@ foreach ( $xml -> post as $productData )
|
||||
$kolor = $product_tmp['Dostępnekoloryjeślidotyczy:untitled_2'];
|
||||
|
||||
$images = explode( '|', $product_tmp['ZdjęciaproduktuURL-e'] );
|
||||
foreach ( $images as $image ) {
|
||||
|
||||
if ( !count( $images ) or ( count( $images ) == 1 and empty( $images[0] ) ) )
|
||||
{
|
||||
if ( isset( $product_images[ $symbol ]['images'] ) )
|
||||
$images = $product_images[ $symbol ]['images'];
|
||||
}
|
||||
|
||||
foreach ( $images as $image )
|
||||
{
|
||||
$productData->{'images_' . $i} = $image;
|
||||
$i++;
|
||||
}
|
||||
@@ -332,6 +340,10 @@ foreach ( $xml -> post as $productData )
|
||||
|
||||
if ( strpos( $Dostępnerozmiaryjeślidotyczy, '|' ) === false )
|
||||
$productsBySymbol[$symbol][] = $productData;
|
||||
else
|
||||
{
|
||||
$product_images[ $symbol ]['images'] = $images;
|
||||
}
|
||||
}
|
||||
|
||||
foreach ($productsBySymbol as $symbol => $products)
|
||||
@@ -366,25 +378,12 @@ foreach ($productsBySymbol as $symbol => $products)
|
||||
}
|
||||
|
||||
// Ensure the product has combinations enabled
|
||||
$start_search_main_product = microtime(true);
|
||||
$mainProduct->checkDefaultAttributes();
|
||||
logTime( "checkDefaultAttributes:", $start_search_main_product );
|
||||
|
||||
$start_search_main_product = microtime(true);
|
||||
Product::updateDefaultAttribute($mainProduct->id);
|
||||
logTime( "updateDefaultAttribute:", $start_search_main_product );
|
||||
|
||||
$start_search_main_product = microtime(true);
|
||||
assignFeatureToProduct($mainProduct->id, 41, 2499);
|
||||
logTime( "assignFeatureToProduct:", $start_search_main_product );
|
||||
|
||||
$start_search_main_product = microtime(true);
|
||||
assignManufacturerToProduct($mainProduct->id, 53);
|
||||
logTime( "assignManufacturerToProduct:", $start_search_main_product );
|
||||
|
||||
$start_search_main_product = microtime(true);
|
||||
updateDeliveryParameters($mainProduct->id);
|
||||
logTime( "updateDeliveryParameters:", $start_search_main_product );
|
||||
|
||||
$productAdded = true;
|
||||
}
|
||||
@@ -462,7 +461,7 @@ foreach ($productsBySymbol as $symbol => $products)
|
||||
$addedCombinations[$key] = true;
|
||||
}
|
||||
|
||||
if ($combinationAdded)
|
||||
if ( $combinationAdded )
|
||||
{
|
||||
if ( !productHasImages($mainProduct->id) and !empty($productData->images_2) )
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user