Commit 412b1882 by halweg

fix

parent 7fc3ee12
......@@ -37,12 +37,15 @@ class ProductFirstImageAsBaseFixer extends Command
protected function execute(InputInterface $input, OutputInterface $output)
{
//$this->fixBaseImage($input, $output, $pid);
$criteria = $this->searchCriteriaBuilder->create();
$products = $this->productRepository->getList($criteria);
$objectManager = \Magento\Framework\App\ObjectManager::getInstance();
foreach ($products as $product) {
$output->writeln('pid' . $product->getId());
$collection = $objectManager->create('Magento\Catalog\Model\ResourceModel\Product\Collection');
foreach ($collection as $item) {
$pid = $item->getId();
if ($pid == '8822') {
$this->fixBaseImage($input, $output, $pid);
}
}
}
......
......@@ -83,24 +83,9 @@ class ImageQueryResource
$select->reset(\Magento\Framework\DB\Select::COLUMNS);
$select->columns(['g.value', 'v.position']);
$select->order('v.position');
//$select->limit(1);
$select->limit(1);
$result = $this->resourceConnection->getConnection()->fetchAll($select);
$minPosition = 2000;
$position = [];
$minImage = '';
foreach ($result as $row) {
if ($row['position'] < $minPosition) {
$minPosition = $row['position'];
$minImage = $row['value'];
$position[$row['position']] = 1;
}
}
if (count($position) > 1) {
return $minImage;
}
return $this->resourceConnection->getConnection()->fetchOne($select);
}
public function updatePosition(int $valueId, int $position)
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment