与本指南相关,我已将我们的商店升级为Magento 1.9.1:
Configurable Swatches Guide for Magento...
问题是缩略图和颜色样本没有播种。在system.log中有这个错误:
2015-01-16T16:56:39+00:00 ERR (3): Notice: Undefined index: product_id in /magento/app/code/core/Mage/ConfigurableSwatches/Helper/Mediafallback.php on line 281
这是代码段:
foreach ($mediaGallery['images'] as $mediaGalleryImage) {
if ($mediaGalleryImage['product_id'] == $product->getId()) {
$newMediaGalleryImages[] = $mediaGalleryImage;
} else {
$configurableImages[] = $mediaGalleryImage;
}
}
当我检查数组时,我找不到$ mediaGalleryImage ['product_id']。我不确定升级是否有问题,或者它是否是一个magento bug。我用rwd主题测试它。
答案 0 :(得分:3)
我遇到了这个确切的问题,在我的情况下,它是第三方扩展名为MageWorx SeoSuite(版本3.13.0)。 我遇到的问题是,当启用可配置样本时,图库图像未显示产品详细信息。 升级到这篇文章(3.14.2)的最新版本仍然没有解决它。
我将其追踪到了“装载画廊”中。班上的方法
MageWorx_XSitemap_Model_Catalog_Resource_Eav_Mysql4_Product_Attribute_Backend_Media
在MageWorx_XSitemap模块中。这会破坏可配置的色板功能。
我不得不暂时在模块config.xml中对它进行评论:
<catalog_resource_eav_mysql4>
<rewrite>
<!-- <product_attribute_backend_media>MageWorx_XSitemap_Model_Catalog_Resource_Eav_Mysql4_Product_Attribute_Backend_Media</product_attribute_backend_media> -->
</rewrite>
</catalog_resource_eav_mysql4>
所以,检查任何类重写。
希望有所帮助。
答案 1 :(得分:0)
<catalog_resource_eav_mysql4>
<rewrite>
<product_attribute_backend_media>MageWorx_XSitemap_Model_Catalog_Resource_Eav_Mysql4_Product_Attribute_Backend_Media</product_attribute_backend_media>
</rewrite>
</catalog_resource_eav_mysql4>
转到MageWorx_XSitemap_Model_Catalog_Resource_Eav_Mysql4_Product_Attribute_Backend_Media类,并将loadGalary函数更新为:
public function loadGallery($product, $object)
{
$eventObjectWrapper = new Varien_Object(
array(
'product' => $product,
'backend_attribute' => $object
)
);
Mage::dispatchEvent(
$this->_eventPrefix . '_load_gallery_before',
array('event_object_wrapper' => $eventObjectWrapper)
);
if ($eventObjectWrapper->hasProductIdsOverride()) {
$productIds = $eventObjectWrapper->getProductIdsOverride();
} else {
$productIds = array($product->getId());
}
$connection = Mage::getSingleton('core/resource')->getConnection('core_write');
$tablePrefix = (string) Mage::getConfig()->getTablePrefix();
$result = $connection->fetchAll("
SELECT `main`.`value_id`, `main`.`value` AS `file`, `main`.`entity_id` AS `product_id`, `value`.`label`, `value`.`position`,
`value`.`disabled`, `default_value`.`label` AS `label_default`, `default_value`.`position` AS `position_default`,
`default_value`.`disabled` AS `disabled_default`
FROM `" . $tablePrefix . "catalog_product_entity_media_gallery` AS `main`
LEFT JOIN `" . $this->getTable(self::GALLERY_VALUE_TABLE) . "` AS `value`
ON main.value_id=value.value_id
AND value.store_id=" . (int) $product->getStoreId() . "
LEFT JOIN `" . $this->getTable(self::GALLERY_VALUE_TABLE) . "` AS `default_value`
ON main.value_id=default_value.value_id AND default_value.store_id=0
WHERE (main.attribute_id = '" . $object->getAttribute()->getId() . "')
AND (main.entity_id in ('" . implode("','", $productIds). "'))
ORDER BY IF(value.position IS NULL, default_value.position, value.position) ASC");
$this->_removeDuplicates($result);
return $result;
}
通过这种方式,您将保留此插件的好处,同时将获得默认的magento颜色样本:) 编码;)