1

約 5,000 の構成可能な製品を備えた Magento ストアがあります。これらの商品については、「色」属性に 29,000 以上のオプションがあります。これにより、ストアの速度が大幅に低下しています (商品詳細ページの読み込みに 10 ~ 20 秒)。

多くの開発者から、直接クエリを使用して速度の問題を回避できると言われています。しかし、実際にこのタスクを達成できた人は 1 人もいません。

ここで誰かがこれを成功させたことがありますか?? 提案、コードなどは大歓迎です。私はここで多くの時間を費やして周りを見回しましたが、この問題に対する具体的な答えは見当たりませんでした.

4

1 に答える 1

1

今日、同様の問題、またはまったく同じ問題が発生したため、解決策を投稿したいと思いました。

私の場合、おそらく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;
}
于 2017-01-03T12:30:03.607 に答える