Skip to content
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
35 changes: 9 additions & 26 deletions Helper/Dimensions.php
Original file line number Diff line number Diff line change
Expand Up @@ -10,35 +10,16 @@

class Dimensions
{
/**
* @var \Magento\Catalog\Model\ResourceModel\Product
*/
private $productResource;

/**
* @var \Magento\Store\Model\StoreManagerInterface
*/
private $storeManager;

/**
* @var \Mygento\Base\Api\ProductAttributeHelperInterface
*/
private $attrHelper;

/**
* @param \Mygento\Base\Api\ProductAttributeHelperInterface $attrHelper
* @param \Magento\Store\Model\StoreManagerInterface $storeManager
* @param \Magento\Catalog\Model\ResourceModel\Product $productResource
*/
public function __construct(
\Mygento\Base\Api\ProductAttributeHelperInterface $attrHelper,
\Magento\Store\Model\StoreManagerInterface $storeManager,
\Magento\Catalog\Model\ResourceModel\Product $productResource,
) {
$this->attrHelper = $attrHelper;
$this->storeManager = $storeManager;
$this->productResource = $productResource;
}
private \Mygento\Base\Api\ProductAttributeHelperInterface $attrHelper,
private \Magento\Store\Model\StoreManagerInterface $storeManager,
private \Magento\Catalog\Model\ResourceModel\Product $productResource,
) {}

/**
* Get items sizes
Expand Down Expand Up @@ -122,9 +103,11 @@ public function dimenAlgo(array $dimensions): array
}

foreach ($dim as $d) {
($d['width'] > $result['width']) ? $result['width'] = $d['width'] : '';
($d['height'] > $result['height']) ? $result['height'] = $d['height'] : '';
$result['length'] += $d['length'];
$length = max($d['length'], $d['width']);
$width = min($d['length'], $d['width']);
($length > $result['length']) ? $result['length'] = $length : '';
($width > $result['width']) ? $result['width'] = $width : '';
$result['height'] += $d['height'];
}
$result['volume'] = $result['length'] * $result['height'] * $result['width'];

Expand Down
Loading