59 lines
1.4 KiB
PHP
59 lines
1.4 KiB
PHP
|
|
<?php
|
||
|
|
|
||
|
|
class MiraviaCombination
|
||
|
|
{
|
||
|
|
|
||
|
|
public $sku = '';
|
||
|
|
public $ean_code = '';
|
||
|
|
public $price = 0;
|
||
|
|
public $special_price = 0;
|
||
|
|
public $quantity = 0;
|
||
|
|
public $images = [];
|
||
|
|
public $width = 0;
|
||
|
|
public $height = 0;
|
||
|
|
public $length = 0;
|
||
|
|
public $weight = 0;
|
||
|
|
public $variation = [];
|
||
|
|
|
||
|
|
public function addVariation($name, $value)
|
||
|
|
{
|
||
|
|
$this->variation[$name] = $value;
|
||
|
|
}
|
||
|
|
|
||
|
|
public function getData()
|
||
|
|
{
|
||
|
|
$combination = [];
|
||
|
|
$this->weight = round((float)$this->weight, 2);
|
||
|
|
foreach ($this as $key => $value){
|
||
|
|
if($key=='ean_code' && empty($value)){
|
||
|
|
continue;
|
||
|
|
}
|
||
|
|
if($key === 'images' && is_array($value) && !empty($value)){
|
||
|
|
$combination['Images'] = ['Image' => $value];
|
||
|
|
} else if($key !== 'images') {
|
||
|
|
$combination[$key] = $value;
|
||
|
|
}
|
||
|
|
}
|
||
|
|
return $combination;
|
||
|
|
}
|
||
|
|
|
||
|
|
public function getStockData()
|
||
|
|
{
|
||
|
|
$combination = [
|
||
|
|
'sku' => $this->sku,
|
||
|
|
'price' => $this->price,
|
||
|
|
'special_price' => $this->special_price,
|
||
|
|
'quantity' => $this->quantity >= 0 ? $this->quantity : 0
|
||
|
|
];
|
||
|
|
return $combination;
|
||
|
|
}
|
||
|
|
|
||
|
|
public function getOnlyStockData()
|
||
|
|
{
|
||
|
|
$combination = [
|
||
|
|
'sku' => $this->sku,
|
||
|
|
'quantity' => $this->quantity >= 0 ? $this->quantity : 0
|
||
|
|
];
|
||
|
|
return $combination;
|
||
|
|
}
|
||
|
|
}
|