简体   繁体   English

如何实现基于权重的magento动态计算价格?

[英]how to implement dynamic calculating price in magento based on weight ?

Hi i'm developing a eCommerce site in Magento for jewellery business and its based on a “weight”, not the price because gold rate is changing in day by day or more then 3 times in a day.So it is not possible to change the product price every time according to gold rate. 嗨,我正在Magento开发一个电子商务网站,用于珠宝业务,其电子商务网站基于“重量”,而不是价格,因为黄金价格每天都在变化,或者一天中发生3次以上。因此无法更改每次按黄金价格计算产品价格。 Then, how to manage the prices on this scenario? 然后,如何在这种情况下管理价格?

Example case: Today I have added a 18K gold ring of 10gm to my site and right now gold rate is Rs30,000 per 10gm, so today price of this ring is Rs30,000 but, Next day the rate will be changed (Rs32,000 per 10gm) then, my product price must be changed from Rs30,000 to Rs32,000. 案例示例:今天,我在网站上添加了10g的18K金戒指,现在的黄金价格为每10g Rs30,000卢比,所以今天这枚戒指的价格为Rs30,000,但第二天价格将更改(Rs32, 000每10克),我的产品价格必须从30,000卢比更改为32,000卢比。

This is not possible to update the price of all products every time. 不可能每次都更新所有产品的价格。 I am using Magento platform. 我正在使用Magento平台。 Please, Share your idea regarding this situation. 请分享您对这种情况的想法。

To make this simple, you should work on a 2 ways solutions. 为简化起见,您应该使用两种方法解决方案。

In the frontend, do not show price ($_product->getPrice()) but just show the real price according to weight. 在前端,不显示价格($ _product-> getPrice()),而仅根据重量显示实际价格。

Example if you have price/grm stored in the backend use $product->getWeight * Mage::getStoreConfig('mycompany/gold/dayprice'). 例如,如果您在后端存储了价格/ grm,请使用$ product-> getWeight * Mage :: getStoreConfig('mycompany / gold / dayprice')。

That way price will be shown dynamically in the product page or list page. 这样,价格将动态显示在产品页面或列表页面中。

Now you should use an Observer on the add to cart event to change the price to the good one. 现在,您应该在添加到购物车事件上使用观察员将价格更改为合适的价格。

This way, don't matter what price is set on the product because showing and adding will use the formulae. 这样,产品的价格设置无关紧要,因为显示和添加将使用公式。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM