문제

현재 Magento는 적용된 카탈로그 가격 규칙보다 낮은 경우 특별 가격을 사용하고 있습니다.

=> 카탈로그 가격 규칙이 특별 가격보다 제품을 저렴하게 만드는 경우 카탈로그 가격 규칙은 상점 가격을 정의합니다.

그러나 나는 이렇게 필요합니다.

카탈로그 가격 규칙을 특별 가격에 적용

Magento 1.8 / p>를 사용하고 있습니다.

및 나는 https://stackoverflow.com/questions/를 사용하여 시도했습니다.18120342 / 카탈로그 - 가격 규칙 - 적용 - 특별 가격

그러나 그것의 저를 위해 일하지 않습니다.

도움이 되었습니까?

해결책

여기에 깊은 분석 후에 해결책을 찾았습니다.

모델을 무시할 수 있습니다

app \ code \ core \ mage \ catalogrule \ model \ action \ index \ refresh.php

 <global>
    <models>
       <catalogrule>
                <rewrite> <action_index_refresh>Yournamespace_Promorule_Model_CatalogRule_Action_Index_Refresh</action_index_refresh></rewrite>
       </catalogrule>            
    </models>
</global>
.

class Yournamespace_Promorule_Model_CatalogRule_Action_Index_Refresh extends Mage_CatalogRule_Model_Action_Index_Refresh {

    /**
     * Prepare temporary data
     *
     * @param Mage_Core_Model_Website $website
     * @return Varien_Db_Select
     */
    protected function _prepareTemporarySelect(Mage_Core_Model_Website $website) {

        /** @var $catalogFlatHelper Mage_Catalog_Helper_Product_Flat */
        $catalogFlatHelper = $this->_factory->getHelper('catalog/product_flat');

        /** @var $eavConfig Mage_Eav_Model_Config */
        $eavConfig = $this->_factory->getSingleton('eav/config');
        $priceAttribute = $eavConfig->getAttribute(Mage_Catalog_Model_Product::ENTITY, 'price');

        $select = $this->_connection->select()
                ->from(
                        array('rp' => $this->_resource->getTable('catalogrule/rule_product')), array()
                )
                ->joinInner(
                        array('r' => $this->_resource->getTable('catalogrule/rule')), 'r.rule_id = rp.rule_id', array()
                )
                ->where('rp.website_id = ?', $website->getId())
                ->order(
                        array('rp.product_id', 'rp.customer_group_id', 'rp.sort_order', 'rp.rule_product_id')
                )
                ->joinLeft(
                        array(
                    'pg' => $this->_resource->getTable('catalog/product_attribute_group_price')
                        ), 'pg.entity_id = rp.product_id AND pg.customer_group_id = rp.customer_group_id'
                        . ' AND pg.website_id = rp.website_id', array()
                )
                ->joinLeft(
                array(
            'pgd' => $this->_resource->getTable('catalog/product_attribute_group_price')
                ), 'pgd.entity_id = rp.product_id AND pgd.customer_group_id = rp.customer_group_id'
                . ' AND pgd.website_id = 0', array()
        );

        $storeId = $website->getDefaultStore()->getId();

        if ($catalogFlatHelper->isEnabled() && $storeId && $catalogFlatHelper->isBuilt($storeId)) {
            $select->joinInner(
                    array('p' => $this->_resource->getTable('catalog/product_flat') . '_' . $storeId), 'p.entity_id = rp.product_id', array()
            );
            $priceColumn = $this->_connection->getIfNullSql(
                    $this->_connection->getIfNullSql(
                            'pg.value', 'pgd.value'
                    ), 'p.price'
            );
        } else {
            $select->joinInner(
                            array(
                        'pd' => $this->_resource->getTable(array('catalog/product', $priceAttribute->getBackendType()))
                            ), 'pd.entity_id = rp.product_id AND pd.store_id = 0 AND pd.attribute_id = '
                            . $priceAttribute->getId(), array()
                    )
                    ->joinLeft(
                            array(
                        'p' => $this->_resource->getTable(array('catalog/product', $priceAttribute->getBackendType()))
                            ), 'p.entity_id = rp.product_id AND p.store_id = ' . $storeId
                            . ' AND p.attribute_id = pd.attribute_id', array()
            );
            $specialPriceAttribute = $eavConfig->getAttribute(Mage_Catalog_Model_Product::ENTITY, 'special_price');
            $specialFormDateAttribute = $eavConfig->getAttribute(Mage_Catalog_Model_Product::ENTITY, 'special_from_date');
            $specialToDateAttribute = $eavConfig->getAttribute(Mage_Catalog_Model_Product::ENTITY, 'special_to_date');


            $todayStartOfDayDate = Mage::app()->getLocale()->date()
                    ->setTime('00:00:00')
                    ->toString(Varien_Date::DATETIME_INTERNAL_FORMAT);

            $todayEndOfDayDate = Mage::app()->getLocale()->date()
                    ->setTime('23:59:59')
                    ->toString(Varien_Date::DATETIME_INTERNAL_FORMAT);

            $select->joinLeft(
                            array(
                        'spd' => $this->_resource->getTable(array('catalog/product', $specialPriceAttribute->getBackendType()))
                            ), 'spd.entity_id = rp.product_id AND spd.store_id = 0 AND spd.attribute_id = '
                            . $specialPriceAttribute->getId(), array()
                    )
                    ->joinLeft(
                            array(
                        'sp' => $this->_resource->getTable(array('catalog/product', $specialPriceAttribute->getBackendType()))
                            ), 'sp.entity_id = rp.product_id AND sp.store_id = ' . $storeId
                            . ' AND sp.attribute_id = spd.attribute_id', array()
            );


            $select->joinLeft(
                            array(
                        'sdfd' => $this->_resource->getTable(array('catalog/product', $specialFormDateAttribute->getBackendType()))
                            ), 'sdfd.entity_id = rp.product_id AND sdfd.store_id = 0 AND sdfd.attribute_id = '
                            . $specialFormDateAttribute->getId(), array()
                    )
                    ->joinLeft(
                            array(
                        'sdf' => $this->_resource->getTable(array('catalog/product', $specialFormDateAttribute->getBackendType()))
                            ), 'sdf.entity_id = rp.product_id AND sdf.store_id = ' . $storeId
                            . ' AND sdf.attribute_id = sdfd.attribute_id', array()
            );

            $select->joinLeft(
                            array(
                        'sdtd' => $this->_resource->getTable(array('catalog/product', $specialToDateAttribute->getBackendType()))
                            ), 'sdtd.entity_id = rp.product_id AND sdtd.store_id = 0 AND sdtd.attribute_id = '
                            . $specialToDateAttribute->getId(), array()
                    )
                    ->joinLeft(
                            array(
                        'sdt' => $this->_resource->getTable(array('catalog/product', $specialToDateAttribute->getBackendType()))
                            ), 'sdt.entity_id = rp.product_id AND sdt.store_id = ' . $storeId
                            . ' AND sdt.attribute_id = sdtd.attribute_id', array()
            );

            $priceColumn = $this->_connection->getCheckSql(
                    '(' . $this->_connection->getIfNullSql(
                            'sp.value', 'spd.value'
                    ) . ' IS NOT NULL AND ((' .
                    $this->_connection->getIfNullSql(
                            'sdf.value', 'sdfd.value'
                    ) . ' IS NULL) OR (' .
                    $this->_connection->getIfNullSql(
                            'sdf.value', 'sdfd.value'
                    ) . ' <= "' . $todayEndOfDayDate . '")'
                    . ') AND ((' .
                    $this->_connection->getIfNullSql(
                            'sdt.value', 'sdtd.value'
                    ) . ' IS NULL) OR (' .
                    $this->_connection->getIfNullSql(
                            'sdt.value', 'sdtd.value'
                    ) . ' >= "' . $todayStartOfDayDate . '")'
                    . '))', $this->_connection->getIfNullSql(
                            'sp.value', 'spd.value'
                    ), $this->_connection->getIfNullSql(
                            $this->_connection->getIfNullSql(
                                    'pg.value', 'pgd.value'
                            ), $this->_connection->getIfNullSql(
                                    'p.value', 'pd.value'
                            )
                    )
            );
        }

        $select->columns(
                array(
                    'grouped_id' => $this->_connection->getConcatSql(
                            array('rp.product_id', 'rp.customer_group_id'), '-'
                    ),
                    'product_id' => 'rp.product_id',
                    'customer_group_id' => 'rp.customer_group_id',
                    'from_date' => 'r.from_date',
                    'to_date' => 'r.to_date',
                    'action_amount' => 'rp.action_amount',
                    'action_operator' => 'rp.action_operator',
                    'action_stop' => 'rp.action_stop',
                    'sort_order' => 'rp.sort_order',
                    'price' => $priceColumn,
                    'rule_product_id' => 'rp.rule_product_id',
                    'from_time' => 'rp.from_time',
                    'to_time' => 'rp.to_time'
                )
        );

        return $select;
    }

}
.

이것이 우리 공동체에 도움이 될 것입니다.

끝에서 모든 입력이 있는지 알려주십시오.

라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 magento.stackexchange
scroll top