public static
getImageItemsChangedByAttributes
(mixed &$item, mixed $attributes, mixed $params, mixed $ajax = 0)
/* Change Image based on Advanced Stock Management */
public static function getImageItemsChangedByAttributes(&$item, $attributes, $params, $ajax = 0)
{
// $paramsC = PhocacartUtils::getComponentParameters();
// $fullAttributes = array();// Array of integers only
$thinAttributes = array();
// Array of full objects (full options object)
if ($ajax == 1) {
// $fullAttributes = PhocacartAttribute::getAttributeFullValues($attributes);
$thinAttributes = $attributes;
} else {
// $fullAttributes = $attributes;
$thinAttributes = PhocacartAttribute::getAttributesSelectedOnly($attributes);
}
// Stock Calculation
// 0 ... Main Product
// 1 ... Product Variations
// 2 ... Advanced Stock Management
// 3 ... Advanced Stock and Price Management
if ($item->stock_calculation == 2 || $item->stock_calculation == 3) {
// Advanced Stock Management
$k = PhocacartProduct::getProductKey((int) $item->id, $thinAttributes);
$dataASM = PhocacartAttribute::getCombinationsDataByKey($k);
$pathItem = PhocacartPath::getPath('productimage');
if (isset($params['typeview']) && ($params['typeview'] == 'Category' || $params['typeview'] == 'Items')) {
$imageSize = 'medium';
} else {
$imageSize = 'large';
// Item, Quickview
}
if (isset($dataASM['image']) && $dataASM['image'] != '') {
$image = PhocacartImage::getThumbnailName($pathItem, $dataASM['image'], $imageSize);
$item->image = Uri::base(true) . '/' . $image->rel;
} else {
// No image found - back to product image
$image = PhocacartImage::getThumbnailName($pathItem, $item->image, $imageSize);
$item->image = Uri::base(true) . '/' . $image->rel;
}
} else {
//Nothing will be set by JS function
$item->image = '';
}
}