Commit 412b1882 by halweg

fix

parent 7fc3ee12
...@@ -37,12 +37,15 @@ class ProductFirstImageAsBaseFixer extends Command ...@@ -37,12 +37,15 @@ class ProductFirstImageAsBaseFixer extends Command
protected function execute(InputInterface $input, OutputInterface $output) protected function execute(InputInterface $input, OutputInterface $output)
{ {
//$this->fixBaseImage($input, $output, $pid); $objectManager = \Magento\Framework\App\ObjectManager::getInstance();
$criteria = $this->searchCriteriaBuilder->create();
$products = $this->productRepository->getList($criteria);
foreach ($products as $product) { $collection = $objectManager->create('Magento\Catalog\Model\ResourceModel\Product\Collection');
$output->writeln('pid' . $product->getId());
foreach ($collection as $item) {
$pid = $item->getId();
if ($pid == '8822') {
$this->fixBaseImage($input, $output, $pid);
}
} }
} }
......
...@@ -83,24 +83,9 @@ class ImageQueryResource ...@@ -83,24 +83,9 @@ class ImageQueryResource
$select->reset(\Magento\Framework\DB\Select::COLUMNS); $select->reset(\Magento\Framework\DB\Select::COLUMNS);
$select->columns(['g.value', 'v.position']); $select->columns(['g.value', 'v.position']);
$select->order('v.position'); $select->order('v.position');
//$select->limit(1); $select->limit(1);
$result = $this->resourceConnection->getConnection()->fetchAll($select); return $this->resourceConnection->getConnection()->fetchOne($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;
}
} }
public function updatePosition(int $valueId, int $position) 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