马本托目录产品价格


Magento catalog product price

代码中,我可以更改"特价"或仅更改每个产品的价格 magento 显示?

我找到了如何在结帐时更改价格,

配置.xml:

<frontend>
    <events>
        <checkout_cart_product_add_after>
            <observers>
                <unique_event_name>
                    <class>discounts/observer</class>
                    <method>modifyPrice</method>
                </unique_event_name>
            </observers>
        </checkout_cart_product_add_after>
    </events>
</frontend>

和观察者:

    <?php
class <namespace>_<module>_Model_Observer
{
    public function modifyPrice(Varien_Event_Observer $obs)
    {
        // Get the quote item
        $item = $obs->getQuoteItem();
        // Ensure we have the parent item, if it has one
        $item = ( $item->getParentItem() ? $item->getParentItem() : $item );
        // Load the custom price
        $price = $this->_getPriceByItem($item);
        // Set the custom price
        $item->setCustomPrice($price);
        $item->setOriginalCustomPrice($price);
        // Enable super mode on the product.
        $item->getProduct()->setIsSuperMode(true);
    }
    protected function _getPriceByItem(Mage_Sales_Model_Quote_Item $item)
    {
        $price = null;
        $price = 10;
        return $price;
    }
}

此代码将所有价格设置为 10$,但仅在"我的购物车"中。

起初我想改变frontend -> events -> THIS EVENT,但找不到任何东西。

您可以使用

catalog_product_load_after 事件来执行此操作,该事件在每次加载模型后直接调用,而不仅仅是在购物车中。