今日、同様の問題、またはまったく同じ問題が発生したため、解決策を投稿したいと思いました。
私の場合、おそらく20kのオプションで構成可能な属性がありました。商品詳細ページの読み込みに時間がかかりました。
いくつかの調査の後、他の ppl にも同様の問題があることがわかりました:
リンク 1
リンク 2
解決策は次のとおりでした。
コピーしました: /app/code/core/Mage/ConfigurableSwatches/Model/Resource/Catalog/Product/Attribute/Super/Collection.php
ローカルへ: /app/code/ local /Mage/ConfigurableSwatches/Model/Resource/Catalog/Product/Attribute/Super/Collection.php
(変更する必要があることに注意してください: $fallbackStoreId変数)
物事をスピードアップするために次の変更を加えました:
/**
* Load attribute option labels for current store and default (fallback)
*
* @return $this
*/
protected function _loadOptionLabels()
{
if ($this->count()) {
$labels = $this->_getOptionLabels();
foreach ($this->getItems() as $item) {
$item->setOptionLabels($labels);
}
}
return $this;
}
/**
* Get Option Labels
*
* @return array
*/
protected function _getOptionLabels()
{
$attributeIds = $this->_getAttributeIds();
// Mage_Catalog_Model_Abstract::DEFAULT_STORE_ID
$fallbackStoreId = 2;
$select = $this->getConnection()->select();
$select->from(array('options' => $this->getTable('eav/attribute_option')))
->join(
array('labels' => $this->getTable('eav/attribute_option_value')),
'labels.option_id = options.option_id',
array(
'label' => 'labels.value',
'store_id' => 'labels.store_id',
)
)
->where('options.attribute_id IN (?)', $attributeIds)
->where(
'labels.store_id IN (?)',
array($fallbackStoreId, $this->getStoreId())
);
$labels = array();
$thisClass = $this;
Mage::getSingleton('core/resource_iterator')->walk(
$select,
array(function($args) use (&$thisClass){
$data = $args['row'];
$labels[$data['option_id']][$data['store_id']] = $data['label'];
})
);
return $labels;
}
/**
* Get Attribute IDs
*
* @return array
*/
protected function _getAttributeIds()
{
$attributeIds = array();
foreach ($this->getItems() as $item) {
$attributeIds[] = $item->getAttributeId();
}
$attributeIds = array_unique($attributeIds);
return $attributeIds;
}