Skip to content

Commit

Permalink
Wip: Manage Products Variants
Browse files Browse the repository at this point in the history
  • Loading branch information
BadPixxel committed Jul 5, 2018
1 parent 02909d7 commit 3064866
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 104 deletions.
4 changes: 4 additions & 0 deletions modules/splashsync/src/Objects/Product/CRUDTrait.php
Original file line number Diff line number Diff line change
Expand Up @@ -77,6 +77,10 @@ public function load($UnikId)
return false;
}

//====================================================================//
// Flush Images Infos Cache
$this->flushImageCache();

return $this->Object;
}

Expand Down
115 changes: 11 additions & 104 deletions modules/splashsync/src/Objects/Product/ImagesTrait.php
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,6 @@
use ImageType;
use ImageManager;
use Tools;
use Db;

/**
* @abstract Access to Product Images Fields
Expand Down Expand Up @@ -155,8 +154,6 @@ private function getImagesFields($Key, $FieldName)
self::lists()->Insert($this->Out, "images", $FieldName, $Index, $Value);
}
unset($this->In[$Key]);

//Splash::log()->www("Get Images", $this->getImagesInfoArray());
}

/**
Expand All @@ -177,8 +174,6 @@ private function setImagesFields($FieldName, $Data)
//====================================================================//
case 'images':
$this->setImgArray($Data);
//Splash::log()->www("Received", $Data);
//Splash::log()->www("Set Images", $this->getImagesInfoArray());
break;

default:
Expand Down Expand Up @@ -363,8 +358,7 @@ public function setImgArray($Data)

//====================================================================//
// Flush Images Infos Cache
$this->ImagesCache = null;
$this->VariantImages = null;
$this->flushImageCache();

return true;
}
Expand Down Expand Up @@ -607,105 +601,8 @@ public function cleanImages($ObjectImagesList)
$ObjectImage->delete();
$this->needUpdate();
}

// $this->cleanBaseProductImages($ObjectImagesList);
// $this->cleanVariantProductImages();
}

// /**
// * @abstract Build Array of Product Attributes Used Images Ids
// * @return array|false
// */
// private function getProductCombinationUsedImagesIds()
// {
// //====================================================================//
// // If Generic Product Mode => Skip
// if (!$this->AttributeId) {
// return false;
// }
// //====================================================================//
// // Read Product Combinations
// $AttrList = $this->Object->getAttributesResume($this->LangId);
// if (empty($AttrList)) {
// return array();
// }
// $Response = array();
// foreach ($AttrList as $AttrResume) {
// //====================================================================//
// // Load Object Images List for Combination
// $PsImages = Image::getImages(
// $this->LangId,
// $this->Object->id,
// $AttrResume["id_product_attribute"]
// );
//
// //====================================================================//
// // Add Image Ids to Response
// foreach ($PsImages as $PsImage) {
// $Response[$PsImage["id_image"]] = $PsImage["id_image"];
// }
// }
// return $Response;
// }
//
// /**
// * @abstract CleanUp Base Product Images List
// * @param array $ObjectImagesList Array Of Remaining Product Images
// * @return void
// */
// private function cleanBaseProductImages($ObjectImagesList)
// {
// //====================================================================//
// // If Variant Product Mode => Skip
// if (empty($ObjectImagesList) || $this->AttributeId) {
// return;
// }
// //====================================================================//
// // If Current Image List Is Empty => Clear Remaining Local Images
// foreach ($ObjectImagesList as $ImageArray) {
// //====================================================================//
// // Fetch Images Object
// $ObjectImage = new Image($ImageArray["id_image"]);
// $ObjectImage->deleteImage(true);
// $ObjectImage->delete();
// $this->needUpdate();
// }
// }
//
// /**
// * @abstract CleanUp Variant Product Images List
// * @return void
// */
// private function cleanVariantProductImages()
// {
// //====================================================================//
// // If Base Product Mode => Skip
// if (!$this->AttributeId) {
// return;
// }
// //====================================================================//
// // Load Object Images List fort Whole Product
// $PsImages = Image::getImages($this->LangId, $this->Object->id);
// //====================================================================//
// // Load List of Used Images List fort Whole Product
// $UsedImages = $this->getProductCombinationUsedImagesIds();
// //====================================================================//
// // If Product Image not Used by Combinations => Clear Local Images
// foreach ($PsImages as $PsImage) {
// //====================================================================//
// // Check if Used
// if (in_array($PsImage["id_image"], $UsedImages)) {
// continue;
// }
// //====================================================================//
// // Fetch Images Object
// $Image = new Image($PsImage["id_image"]);
// $Image->deleteImage(true);
// $Image->delete();
// $this->needUpdate();
// }
// }

/**
* @abstract Update Product Image Thumbnail
*/
Expand Down Expand Up @@ -733,4 +630,14 @@ private function updateImgThumbnail()
}
}
}

/**
* @abstract Flush Product Images Reading Cache
* @retrurn void
*/
private function flushImageCache()
{
$this->ImagesCache = null;
$this->VariantImages = null;
}
}

0 comments on commit 3064866

Please sign in to comment.