久久久久久久av_日韩在线中文_看一级毛片视频_日本精品二区_成人深夜福利视频_武道仙尊动漫在线观看

自動在 Magento 中創建購物車價格規則

Creating a shopping cart price rule in Magento automatically(自動在 Magento 中創建購物車價格規則)
本文介紹了自動在 Magento 中創建購物車價格規則的處理方法,對大家解決問題具有一定的參考價值,需要的朋友們下面隨著小編來一起學習吧!

問題描述

我想創建一個購物車價格規則,當用戶在我的 Magento 網站上完成一個流程時,他們可以享受 10% 的訂單折扣.

I'd like to create a shopping cart price rule that gives a user 10% off their order when and if they complete a process on my Magento site.

此處有一種方法可以將規則直接插入到數據庫中.這有點侵犯我的口味.

There's a method here that inserts the rule directly to the database. That's a bit invasive for my tastes.

我將如何使用 Magento 方法來解決這個問題?

How would I go about this using Magento methods?

推薦答案

作為一般原則,您應該能夠完成 Magento 系統本身所做的任何事情,而無需編寫一行 SQL.幾乎所有的 Magento 數據結構都使用 Magento Model 類.

As a general principle, you should be able to do anything that the Magento system itself does without writing a single line of SQL. Almost all the Magento data structures use Magento Model classes.

在某處運行以下代碼以查看銷售規則/規則模型的樣子.這假設您已經在管理員中創建了一個 ID 為 1 的購物車價格規則

Run the following code somewhere to see what a salesrule/rule model looks like. This assumes you've created a single Shopping Cart Price Rule in the admin with an ID of 1

    $coupon = Mage::getModel('salesrule/rule')->load(1);
    var_dump($coupon->getData());

以轉儲的數據為指導,我們可以使用以下方法以編程方式創建模型

Using the dumped data as a guide, we can programatically create a model using the following

    $coupon = Mage::getModel('salesrule/rule');
    $coupon->setName('test coupon')
    ->setDescription('this is a description')
    ->setFromDate('2010-05-09')
    ->setCouponCode('CODENAME')
    ->setUsesPerCoupon(1)
    ->setUsesPerCustomer(1)
    ->setCustomerGroupIds(array(1)) //an array of customer grou pids
    ->setIsActive(1)
    //serialized conditions.  the following examples are empty
    ->setConditionsSerialized('a:6:{s:4:"type";s:32:"salesrule/rule_condition_combine";s:9:"attribute";N;s:8:"operator";N;s:5:"value";s:1:"1";s:18:"is_value_processed";N;s:10:"aggregator";s:3:"all";}')
    ->setActionsSerialized('a:6:{s:4:"type";s:40:"salesrule/rule_condition_product_combine";s:9:"attribute";N;s:8:"operator";N;s:5:"value";s:1:"1";s:18:"is_value_processed";N;s:10:"aggregator";s:3:"all";}')
    ->setStopRulesProcessing(0)
    ->setIsAdvanced(1)
    ->setProductIds('')
    ->setSortOrder(0)
    ->setSimpleAction('by_percent')
    ->setDiscountAmount(10)
    ->setDiscountQty(null)
    ->setDiscountStep('0')
    ->setSimpleFreeShipping('0')
    ->setApplyToShipping('0')
    ->setIsRss(0)
    ->setWebsiteIds(array(1));      
    $coupon->save();

對于任何好奇的人,以上是使用此處

For anyone that's curious, the above is generated code, using the technique discussed here

這篇關于自動在 Magento 中創建購物車價格規則的文章就介紹到這了,希望我們推薦的答案對大家有所幫助,也希望大家多多支持html5模板網!

【網站聲明】本站部分內容來源于互聯網,旨在幫助大家更快的解決問題,如果有圖片或者內容侵犯了您的權益,請聯系我們刪除處理,感謝您的支持!

相關文檔推薦

Override Magento Config(覆蓋 Magento 配置)
What would cause a print_r and/or a var_dump to fail debugging a variable?(什么會導致 print_r 和/或 var_dump 調試變量失敗?)
How to update custom options programatically in magento?(如何在 magento 中以編程方式更新自定義選項?)
Magento 404 on Admin Page(管理頁面上的 Magento 404)
Magento - get price rules from order(Magento - 從訂單中獲取價格規則)
Magento Change Product Page Titles to Include Attributes(Magento 更改產品頁面標題以包含屬性)
主站蜘蛛池模板: 亚洲一级av毛片 | 五月婷婷激情网 | 老熟女毛片 | 精品国产欧美日韩不卡在线观看 | 少妇午夜一级艳片欧美精品 | 日韩午夜电影在线观看 | 精品一区二区久久久久久久网站 | 精品国产不卡一区二区三区 | 一区二区免费在线观看 | 2018天天干天天操 | 欧美自拍第一页 | 夜夜草天天草 | 日本一区不卡 | 日韩精品一区二区三区视频播放 | 午夜网址 | 每日在线更新av | 久久综合香蕉 | 国产精品自拍一区 | 亚洲欧美综合 | 久久精品| 免费不卡av | 日韩欧美高清 | 欧美在线一区二区三区 | 国产激情视频 | 国产激情免费视频 | 狠狠躁夜夜躁人人爽天天高潮 | 欧美一级全黄 | 伊人在线 | 欧美日韩一 | 一区二区国产在线观看 | 国产黄色网| 欧美区在线| 久久国产精品免费一区二区三区 | 国产美女h视频 | 国产精品一区二区欧美 | 日韩精品在线观看一区二区 | 久久成人免费 | 99riav国产一区二区三区 | 日韩中文欧美 | 国产精品永久久久久久久www | 91色综合|