Answers:
您可以找到以下代码的集合。
$_products = Mage::getModel('catalog/product')
->getCollection()
->addAttributeToSelect('*')
->addAttributeToFilter(array(
array (
'attribute' => 'image',
'like' => 'no_selection'
),
array (
'attribute' => 'image', // null fields
'null' => true
),
array (
'attribute' => 'image', // empty, but not null
'eq' => ''
),
array (
'attribute' => 'image', // check for information that doesn't conform to Magento's formatting
'nlike' => '%/%/%'
),
));
您可以获得没有分配图像的所有产品列表。
如果您只想要没有的产品image
,small_image
或者thumbnail
分配然后从@KeyulShah或@TBIInfotech的答案将只是给你。
如果您想要完全没有图像的产品,则可以在数据库上运行此查询并获取它们。
SELECT
e.sku, COUNT(m.value) as cnt
FROM
catalog_product_entity e
LEFT JOIN catalog_product_entity_media_gallery m
ON e.entity_id = m.entity_id
GROUP BY
e.entity_id
HAVING
cnt = 0
如果删除 having
语句,您将获得两列结果,其中包含产品skus和分配给它们的图像数。
您可以将其导出为csv。
只是对@keyul shah所描述的内容进行了小小的修改,只需将代码放在magento root上即可:
<?php
require 'app/Mage.php';
Mage::app();
$_products = Mage::getModel('catalog/product')
->getCollection()
->addAttributeToSelect('*')
->addAttributeToFilter(array(
array (
'attribute' => 'image',
'like' => 'no_selection'
),
array (
'attribute' => 'image', // null fields
'null' => true
),
array (
'attribute' => 'image', // empty, but not null
'eq' => ''
),
array (
'attribute' => 'image', // check for information that doesn't conform to Magento's formatting
'nlike' => '%/%/%'
),
));
foreach($_products as $_product){
echo $_product->getSku();
}
这对我有用...
$products = Mage::getModel('catalog/product')
->getCollection()
->addAttributeToSelect('*')
->addAttributeToFilter(
array(
array(
'attribute' => 'image',
'null' => '1'
),
array(
'attribute' => 'small_image',
'null' => '1'
),
array(
'attribute' => 'thumbnail',
'null' => '1'
),
array(
'attribute' => 'image',
'nlike' => '%/%/%'
),
array(
'attribute' => 'small_image',
'nlike' => '%/%/%'
),
array(
'attribute' => 'thumbnail',
'nlike' => '%/%/%'
)
),
null,
'left'
);
如果有人在寻找Magento2。这将起作用。与@Marius相同,只是添加了一张表。
SELECT
e.sku, COUNT(m.value) as cnt
FROM catalog_product_entity e
LEFT JOIN catalog_product_entity_media_gallery_value_to_entity r
ON e.entity_id = r.entity_id
LEFT JOIN catalog_product_entity_media_gallery m
ON r.value_id = m.value_id
GROUP BY
e.entity_id
HAVING
cnt = 0