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