<?php
/**
* Created by Elements.at New Media Solutions GmbH
*
*/
namespace App\Model\DataObject;
class Product extends \Pimcore\Model\DataObject\Product
{
/**
* Overridden class because we need to set Objectsbricks dynamically via Importer
*
* @return \Pimcore\Model\DataObject\Objectbrick|null
*/
public function getOrCreateProductSpecificationBrick(string $brickName)
{
$brickName = str_replace(['-', ' '], '', $brickName);
$brickGetter = 'get' . ucfirst($brickName);
$brickSetter = 'set' . ucfirst($brickName);
$brickClass = '\\Pimcore\\Model\\DataObject\\Objectbrick\\Data\\' . ucfirst($brickName);
$brickDefinition = \Pimcore\Model\DataObject\Objectbrick\Definition::getByKey($brickName);
if ($brickDefinition) {
if ($specification = $this->getSpecification()) {
if (!$brick = $specification->$brickGetter()) {
$brick = new $brickClass($this);
$specification->$brickSetter($brick);
}
return $brick;
}
}
return null;
}
public function getObjectBrickAttributes(): mixed
{
$attributes = [];
if ($specification = $this->getSpecification()) {
if ($specification->getItems()[0] ?? false) {
$items = $specification->getItems()[0];
if ($specification->getItems()[0]->getType() == 'PalfingerLoaderCrane') {
$methods = ['maxLiftMoment', 'maxLiftCapacity', 'maxHydraulicOutreach', 'maxManualOutreach', 'slewingAngle', 'slewingTorqueOneGear', 'stabilizerSpread', 'fittingSpaceRequired', 'widthFolded', 'maxOperatingPressure', 'pumpCapacity', 'deadWeight', 'slewingTorqueTwoGears', 'maxOutreachFlyJib', 'recomPumpCaRSQ240', 'recomPumpCaRSQ240_2', 'RecomPumpCaPVG32Radio_2', 'RecomPumpCaPVG32_2'];
foreach ($specification->getItems()[0]->getTable() as $row => $tableItems) {
foreach ($tableItems as $key => $value) {
if ($value != null || $value != '') {
if ($row == 0) {
$attributes['table']['head'][$key] = $value;
} else {
$attributes['table']['body'][$row][$key] = $value;
}
}
}
}
foreach ($specification->getItems()[0]->getAdditionalImages() as $image) {
$attributes['images'][] = $image;
}
}
elseif ($specification->getItems()[0]->getType() == 'PalfingerAccessplatform') {
$methods = ['maxHeightofWork', 'maxbasketfloorheight', 'maxhorizontaloutreach', 'maxbasketcapacity', 'workmanbasket', 'neigungswinkelTeleskoparm', 'schwenkbereichDrehtisch', 'hoeheTransportstellung', 'breiteTransportstellung'];
foreach ($specification->getItems()[0]->getAdditionalImages() as $image) {
$attributes['images'][] = $image;
}
}
elseif (str_starts_with($specification->getItems()[0]->getType(), 'Komatsu')) {
$methods = [
'enginePower', 'operatingWeight', 'spoonCapacity', 'diggingDepth', 'bucketCapacity',
'bodyCapacity', 'ratedPayload', 'maxSpeed', 'speed', 'breakoutForce', 'tippingLoad',
'crushingCapacity', 'blade', 'bladeCapacity', 'bladeSize', 'ownWeight', 'power', 'grossLoad',
'maxOperatingPressure', 'torque', 'tractionForce', 'sizes', 'netWeight', 'engine', 'craneBucket',
'hydraulicSystem', 'electricSystem', 'transmission', 'height', 'width', 'knivesOpen', 'rollerOpening',
'strippedDiameter', 'feedSpeed', 'rollerDiameter', 'grossDosingForce', 'numberKnives', 'bottomDiameter',
'rollerOpening', 'sawBlade', 'sawMotor', 'maxHydraulicFlow', 'cylinderVolume',
'crane', 'availableHeads',
];
}
else {
$methods = [
'baseMachineWeight', 'feedHeight', 'feedingWidth', 'emissionMass', 'numberQuickChangeBlades',
'drumDiameter', 'intake', 'control', 'propulsion', 'driveSpeed',
'drivePower', 'grates', 'chassis', 'rotorShaftDiameter', 'factoryCraneDesign',
'grossLoad', 'torque', 'emissionStandard', 'powerNm', 'fuel',
'netWeight', 'craneBucket', 'hydraulicSystem', 'electricSystem',
'transmission', 'ownWeight', 'strippedDiameter', 'feedSpeed',
'width', 'knivesOpen', 'rollerOpening', 'rollerDiameter', 'grossDosingForce',
'numberKnives', 'bottomDiameter', 'sawBlade', 'sawMotor', 'maxHydraulicFlow',
'maxOperatingPressure', 'cylinderVolume', 'tractionForce', 'sizes',
'engine', 'crane', 'availableHeads',
'loadCapacity', 'liftHeight', 'maxLiftCapacity', 'maxExtension', 'maxWeight',
'driveUnit', 'stockpileHeight', 'weight', 'transportHeight', 'transportWidth',
'transportLength', 'power', 'tires', 'tractionDrive', 'additionalHydraulic',
'deadWeight', 'maxLiftingHeight', 'speedWithoutLoad', 'speedWithLoad', 'tareWeight',
'maxPayload', 'heaped', 'throughput', 'transportDimensions', 'workingDimensions',
'crushingGapWidth', 'sizeOfTank', 'numberPaddlesBlades', 'sizeMotorGearbox', 'config',
'screenSize', 'engineSize', 'length', 'height', 'drive',
'hopperCapacity', 'driveMotorGearbox', 'feedConveyor', 'cycloneSize', 'pumpSize',
'operatingWeight', 'maxLiftingCapacity', 'maxBoomReach', 'enginePower', 'winch',
'winchForce', 'maxHookHeight', 'carryingCapacity', 'hydraulicExcavator', 'massRipperWithTopBracket',
'massRipperWithoutTopBracket', 'hydraulicWorkingPressure', 'hydraulicReturnPressure', 'requiredOilAmount', 'maxCaseDrainPressure',
'frequency', 'dimensions', 'accumulatorPressure', 'liftingForce', 'breakoutForce',
'thrust', 'avgGroundPressure', 'turningRadius', 'articleNumber',
'additionalText',
];
}
foreach ($methods as $method) {
$getter = 'get' . ucfirst($method);
if (method_exists($items, $getter)) {
if ($items->$getter()) {
$attributes['attributes']['th'][] = $method;
$attributes['attributes']['td'][] = $items->$getter();
}
}
}
}
}
return $attributes;
}
public function getTeaserAttributes(): mixed
{
$attributes = [];
if ($specification = $this->getSpecification()) {
if ($specification->getItems()[0] ?? false) {
if ($specification->getItems()[0]->getType() == 'PalfingerLoaderCrane') {
$items = $specification->getItems()[0];
$prefixTk = 'palfinger.';
$attributes[$prefixTk . 'maxLiftCapacity'] = $items->getMaxLiftCapacity();
$attributes[$prefixTk . 'deadWeight'] = $items->getDeadWeight();
}
elseif (str_starts_with($specification->getItems()[0]->getType(), 'Komatsu')) {
$type = $specification->getItems()[0]->getType();
$items = $specification->getItems()[0];
$prefixTk = 'komatsu.';
if ($type == 'KomatsuElektrischeMuldenkipper' || $type == 'KomatsuMuldenkipper') {
$attributes[$prefixTk . 'bodyCapacity'] = $items->getBodyCapacity();
$attributes[$prefixTk . 'ratedPayload'] = $items->getRatedPayload();
} elseif ($type == 'KomatsuKnickgelenkteMuldenkipper') {
$attributes[$prefixTk . 'operatingWeight'] = $items->getOperatingWeight();
$attributes[$prefixTk . 'ratedPayload'] = $items->getRatedPayload();
} elseif ($type == 'KomatsuKompaktlader' || $type == 'KomatsuKompaktradlader' || $type == 'KomatsuRadlader') {
$attributes[$prefixTk . 'operatingWeight'] = $items->getOperatingWeight();
$attributes[$prefixTk . 'bucketCapacity'] = $items->getBucketCapacity();
} elseif ($type == 'KomatsuMobileBackenbrecher' || $type == 'KomatsuMotorGrader' || $type == 'KomatsuPlanierraupen') {
$attributes[$prefixTk . 'operatingWeight'] = $items->getOperatingWeight();
$attributes[$prefixTk . 'enginePower'] = $items->getEnginePower();
} elseif ($type == 'KomatsuForestHarvesterHeads') {
$attributes[$prefixTk . 'ownWeight'] = $items->getOwnWeight();
$attributes[$prefixTk . 'maxOperatingPressure'] = $items->getMaxOperatingPressure();
} elseif ($type == 'KomatsuForestHarvester') {
$attributes[$prefixTk . 'ownWeight'] = $items->getOwnWeight();
$attributes[$prefixTk . 'power'] = $items->getPower();
}elseif ($type == 'KomatsuForestForwarder') {
$attributes[$prefixTk . 'grossLoad'] = $items->getGrossLoad();
$attributes[$prefixTk . 'power'] = $items->getPower();
} else {
$attributes[$prefixTk . 'operatingWeight'] = $items->getOperatingWeight();
$attributes[$prefixTk . 'spoonCapacity'] = $items->getSpoonCapacity();
}
}
else {
$type = $specification->getItems()[0]->getType();
$items = $specification->getItems()[0];
$prefixTk = 'manual.';
if ($type == 'Frd') {
$attributes[$prefixTk . 'baseMachineWeight'] = $items->getBaseMachineWeight();
} elseif ($type == 'Powerscreen') {
$attributes[$prefixTk . 'throughput'] = $items->getThroughput();
}
}
}
}
return $attributes;
}
}