
magento Developers
ddjohn
coder
展开
-
Magento的路由分发机制
有半年没写东西了吧 不是没继续学 确实是懒了 好吧 言归正传!Magento的路由主要为了完成以下三个任务:1.接收并处理浏览器数据讲它传送给系统的其他部分;2.定义controller和action来供routes使用;3.展示浏览器请求数据给blocks,templates和model数据。其中最核心的前端Controller是Mage_Core_Contr原创 2013-06-08 17:37:46 · 2299 阅读 · 0 评论 -
Add custom Field in Order Total for Magento
如果在Magento的订单或者email中的total中加多自定义的一项,跟踪代码后发现,一切皆在Mage_Sales_Block_Order_Totals这个Block中,在_initTotals()这个function里面定义了多个fields,包括shipping,discount,grandtotal等等。加多一个叫freeGift的field吧,代码比较粗糙,同样抛砖引玉:原创 2012-04-27 17:43:14 · 1323 阅读 · 0 评论 -
Add Custom Info on Invoice Pdf for Magento
如何在打印出来的Pdf里面增加额外信息,其实只要知道如何操纵数据,最终打印的handle还是Zend来执行,Magento内置了Zend_Pdf类,用他来打印PDF文件,下面是一个示例,比较简单易懂,在此抛砖引玉。以下代码加在Mage_Sales_Model_Order_Pdf_Invoice这个类中。 /* Gfit Msg Notice */ $freegiftboxHandle原创 2012-04-27 17:22:44 · 1227 阅读 · 0 评论 -
Magento "Source model metarobots/product_attribute_source_unit not found for attribute"
在使用Yoast_Robot的时候发现一个致命错误 Source model metarobots/product_attribute_source_unit not found for attribute 其实已经删了,后来才发现原来属性没删,core_resource里面也没清理干净...执行如下的SQL语句便可:DELETE FROM `eav_attribute` WHERE `eav翻译 2012-04-12 17:01:03 · 1323 阅读 · 0 评论 -
自定义Events&Observer来实现订单评论(Custom Order Comments)
除了强大的面向对象机制,比如重写或者继承来覆盖Magento本身的行为之外,还可以通过事件观察者模式来更新Magento固有的工作线路。事件(Events)是发生在某一特定的地方的顺序流。打个比方说,客户下订单的顺序流:1. 保存订单的详细信息2. 发送订单的确认信息给客户事件则可能在邮件的发出之前或者之后来引入自定义逻辑。观察者(Observer)是一个事件的原创 2012-03-25 18:03:24 · 1390 阅读 · 0 评论 -
Magento Paypal checkout not send new order email(使用Paypal checkout时无法收到新订单邮件)
碰到一个问题,使用Paypal checkout时无法收到新订单邮件,后来找到了原因app/code/core/Mage/Checkout/Model/Type/Onepage.php这个文件做了发送邮件的判断,只有在没有使用第三方的情况下才发送邮件,删掉判断就没问题了。if(!$redirectUrl){ try { $order->sendNewOrderEmail();原创 2012-03-07 17:24:26 · 2041 阅读 · 0 评论 -
让Magento生成的PDF打印图片(Magento invoice shipment pdf add product images)
应公司的要求,尝试着在magento打印出来的invoice和shipment中打印产品图片。于是乎参考了电商中国的http://www.ecartchina.com/display-products-images-on-pdf.html和Inchoo的http://inchoo.net/ecommerce/magento/magento-pdf-invoice-with-product-imag原创 2012-03-05 17:30:37 · 2192 阅读 · 0 评论 -
Magento Error:Invalid model for shipping method
之前因为偷懒去改内核,copy默认的flat rate做为一个自定义的shipping method的时候有些文件没有完全删除导致在order ship里面出现错误,还原内核刷新缓存还是没法解决,于是乎想到了数据库问题,网上搜索了一下,才发现shipping method创建的时候把一些key写入了core_config_data的表里,我所创建的shipping method key是yipsh原创 2012-03-01 14:18:58 · 1226 阅读 · 0 评论 -
Magento An error occurred while saving the URL rewrite (索引刷不了怎么办)
如果你发现Magento的索引没法刷新,尝试下列方法:1.将media文件夹的权限更改为7772.直接删除/var/cache这个缓存文件夹3.删除session文件夹/var/sessions4.将根目录下的.htaccess替换成你对应的magento版本的默认.htaccess如果上面的做法还是不行的话,那么好吧,强制改代码执行app/code/core/Mage/C原创 2012-02-29 14:19:19 · 2014 阅读 · 0 评论 -
Magento 新闻模块开发教程 (四) 创建模块的xml配置文件
上一章我们好不容易创建好控制器,这里我们继续为magento创建模块配置文件,在app/code/local/Voodoo/News/etc下,我这里是app/code/local/Voodoo/News/etc下创建一个config.xml文件: 0.1.0 standard原创 2011-07-08 15:07:19 · 1708 阅读 · 0 评论 -
Magento外部Add to cart操作(广告需要)
quick shopping Sku: Qty: Add to cart 以前觉得外部add to cart没什么用,后来才发现可以再帮我们坐推广的网站上使用,其实网站外只需要几行html代码,把如上代码放在外部:然后add to cart的时候需要做了一跳转:<?php include_once 'app/Mage.php'; Mage:原创 2012-02-21 17:43:38 · 2576 阅读 · 0 评论 -
Magento 如何获取一个产品资源集合?
$category_id = 20;$_productCollection = Mage::getModel('catalog/category')->load($category_id) ->getProductCollection() ->addAttributeToSelect('*') ->addAttributeToFilter('status', 1) ->addAttrib原创 2012-01-02 13:05:24 · 1205 阅读 · 0 评论 -
Magento 语言 货币 根据访问者的IP自动转换
Magento 语言 货币 如何根据访问者的IP自动转换?这个相信很多人都比较感兴趣的,其实有一个比较方便的现成插件就是MageWorx的Auto switcherhttp://www.magentocommerce.com/magento-connect/store-and-currency-auto-switcher.html,这个可以轻松实现你想要的功能。里面主要的核心技术应该属于GeoIP转载 2012-05-08 15:33:04 · 2168 阅读 · 0 评论 -
Magento结账时如何移除运费选择步骤(Skip shipping step on onepage checkout)
1.修改app\code\core\Mage\Checkout\Block \Onepage.php 我们需要做的是修改默认的step,就是修改getStep functionpublic function getSteps() { $steps = array(); if (!$this->isCustomerLoggedIn()) { $steps['login'] = $this原创 2012-05-27 16:02:20 · 2909 阅读 · 2 评论 -
给Block输出的html设置缓存
Magento的缓存类型分好几种 其中一种是Block的html缓存 俗称静态化(非伪静态),理解Magento的缓存 得先了解它的模版体系 这里不多解析了。总而言之,Magento只能做基于Block的局部缓存,给这些Block做缓存其实很简单,默认情况下开启缓存的Block只是极少数,比如Footer是其中一个,毕竟footer需要更新数据的频率很低。 protected funct翻译 2012-06-21 16:47:05 · 1209 阅读 · 0 评论 -
Magento模块调用的过程和逻辑
1.在调用每个Magento模块(Modules)的时候,首先会返回Mage_Core_Model_Config 这个模型 它里面呈现了模块的一些常规配置,比如是否生效(enabled),版本(version)等等。Mage_Core_Model_Congif这个模型中有这么一个方法,来完成上面所说的功能。 /** * Get module config node *翻译 2012-06-21 18:21:27 · 1703 阅读 · 0 评论 -
Recoverable Error: Argument 1 passed to Mage_SalesRule_Model_Validator::process()
使用J2t的rewardpoints插件,cart页面选择区域计算运费时出现如下类似的错误:Recoverable Error: Argument 1 passed to Mage_SalesRule_Model_Validator::process() must be an instance of Mage_Sales_Model_Quote_Item_Abstract, instanc原创 2012-06-11 16:44:56 · 1464 阅读 · 0 评论 -
Magento操作Cookie 并且使用观察者&事件来禁用单页面全页缓存(EE FPC)
Groupon(http://www.groupon.hk/)的首次访问会弹出一个框让客户输入电子邮件来订阅他们的最新咨询,只要提交表单或者点已经提交的按钮该框就会消失 并且以后访问都不会出现 大家应该见过 最近按照公司的要求需要在magento里面开发类似的效果。 首先明确这其中使用的原理是cookie 那magento该怎么操纵cookie呢 其实在core的model里面有一个cooki原创 2012-08-17 15:34:27 · 2723 阅读 · 0 评论 -
Magento设置cronjob来让系统自动发送newsletter
用Newsletter来让Magento系统自动发送邮件给已经subscribe的客户email,相信应该是很多人想知道具体怎么操作的,在此小生说明下,有错误的地方欢迎指正!要让系统自动发送邮件 需要设置cronjob这个东西,他可以自动帮我们完成一些计划任务,这是针对Unix linux机器而言的。linux机器进去Terminal,如果是用虚拟机或者vps进去ssh命令行输入:cronta原创 2012-12-12 15:46:06 · 3531 阅读 · 0 评论 -
magento的运费模块开发教程(Customize Magento Shipping Module Tutorial)
好久好久没写文章了 已经懒了,之前翻译过一篇关于Magento新闻模块的开发教程,今天再写一篇Shipping Module的模块开发教程吧,示例出自Jamie Huskisson的《Magento 1.3: PHP Developer's Guide》,我按自己的意识表达 就不做翻译了,如果错误之处,欢迎指正吐槽!1.搭一个模块 肯定要先告诉magento模块的配置文件吧,所以在ap翻译 2012-12-04 15:45:15 · 2754 阅读 · 1 评论 -
Magento SOAP API基础知识
http://www.magentocommerce.com/api/soap/introduction.html这篇官网作为Magento API操作的基本知识还是不错的 有时间得翻译下翻译 2012-07-31 23:47:26 · 1846 阅读 · 0 评论 -
Magento how to remove system attribute?(如何移除系统属性)
magento系统自带的属性是无法删除了,除非是用户自定义。所以要删除它,必须跑到数据库里面删。1.登录mysql,phpmyadmin,mysql browser都行,或者直接mysql命令行2.找到eav_attribute这个表,通过label或者code找到你想要删除的属性3.把is_user_defined这个字段设置为1就表示是用户自定义的,可以在后台删除,当然,你直接删除原创 2012-05-25 12:38:31 · 1974 阅读 · 0 评论 -
使用TortoiseSVN来管理Magento代码
TortoriesSVN是一个免费开源的SVN版本管理系统,可以在windows,linux或者mac机上使用,关于tortoriesSVN可以在http://tortoisesvn.net/上下载到。Magento CE提供了SVN的链接:svn checkout http://svn.magentocommerce.com/source/branches/1.7 而如果你使用Tortor原创 2012-05-24 12:47:01 · 1470 阅读 · 0 评论 -
Magento Warning: PDO::quote() expects parameter 1 to be string, object given in
Looks like there are a few people having the same issue I was having with Magento regarding the “Warning: PDO::quote() expects parameter 1 to be string…” error after updating to 1.4. Have no fear! The转载 2011-12-21 13:24:58 · 2958 阅读 · 0 评论 -
Magento 如何在产品页获取当前产品的销量
已经可以在自定义的bestseller模块下获取销量,bestseller模块可以直接引用数组中ordered_qty的值$_product->ordered_qty;如果是在产品页面就比较麻烦,我们必须获取reports/product_collection这个资源类的实例,然后再进行筛选。写法各不相同、$reportCollection = Mage::getResourceModel原创 2011-11-19 16:39:59 · 1751 阅读 · 0 评论 -
Getting Ordered Items and their Detail from Order ID in Magento
<br />Here is a small snippet of code, yet useful, to get ordered items and its details. I’ve deviced this code a lot before and posted in Magento Commerce’s Forum as well. But felt like writting it again, so that I can have a quick refrence to it as转载 2011-03-23 13:04:00 · 1168 阅读 · 0 评论 -
How to add some custom registration fields while creating your magento account?(compatible also for 1.4.2.0 version)
1.Magento采用实体-值-属性(EVA)的灵活方式来操纵数据 实体为数据项目的描述,属性是一个属性定义表的外键约束,值则为属性的值2.为magento添加新的EVA,比如在用户注册页面添加一个ICQ的字段让用户填写自己的ICQ,你可以在app/design/frontend/YOUR_PACKAGE/YOUR_THEME/template/customer/form/regiter.phtml里面添加代码: $setup = new Mage_Eav_Model_Entity_Setup('原创 2011-03-18 15:21:00 · 2285 阅读 · 3 评论 -
Fatal error: Call to a member function setAttribute() on a non-object in Magento
<br />升级到1.4.20版本,出现 Fatal error: Call to a member function setAttribute() on a non-object in 的错误,有些头痛,后来网上找到解决办法:<br />在app/code/core/Mage/Eav/Model/Entity/Attribute/Abstract.php 第374行 将<br /><br />$this->_source = Mage::getModel($this->getSourceModel())<转载 2010-12-28 09:33:00 · 3375 阅读 · 0 评论 -
magento connect manage出现404或者500内部错误的解决办法
Directory /downloader/ set to 755file /downloader/index.php set to 644原创 2010-10-05 00:05:00 · 1836 阅读 · 0 评论 -
关于currency显示的问题
<br />1.currency setup的设置<br />2.system ——manage currency rate的管理<br />3.cache原创 2010-10-01 09:52:00 · 1226 阅读 · 0 评论 -
如何迁移你远程主机上的magento到本地主机安装
<br /><br />有几个方法来管理这一过程:*通过 使用SSH *通过 的FTP *自动 PHP的 (迁移Magento 自动化脚本)<br />在这里,我从我的远程主机迁移到我的XAMPP例如本地测试环境,因为我第一次安装在我的远程主机magento然后我想在我的发展速度和方便硬盘驱动器。 一些偏远的托管公司提供脚本安装,它是更快地安装它magento。<br />1。 始终创建数据库从magento骨干/管理面板“>系统”>工具“>备份>”创建备份转储,然后下载的“gz”点击转储文件。 保存在一个翻译 2010-08-02 13:50:00 · 1495 阅读 · 0 评论 -
30 Essential Free Magento Extensions
Magento is a popular open source platform to built your ecommerce website. It is based on Zend Framework and has a very flexible architecture. Although it is much younger than many of its competitors, Magento has a large community of users. Developers can转载 2010-07-22 16:25:00 · 1514 阅读 · 0 评论 -
后台产品页显示产品缩略图的插件
Key:magento-community/TBT_Enhancedgrid-1.2转载 2010-07-20 10:58:00 · 916 阅读 · 0 评论 -
后台Block注入的写法范例(筛选属性和目录id)
{{block type="catalog/product_list" category_id="6" template="catalog/product/list.phtml"}} {{block type="catalog/product_list" attribute_code="myAttribute" attribute_value="myValue" template="catalog/product/list.phtml"}}原创 2010-07-15 14:34:00 · 1041 阅读 · 0 评论 -
深入理解magento
Model-View-Controller (MVC) ,模型-视图-控制器,源于Smalltalk编程语言和Xerox Parc。现在有很多系统是基于MVC架构的,不同的系统MVC的实现也略有不同,但都体现了MVC的精髓,分离数据,业务逻辑和显示逻辑。最常见的PHP MVC框架是这样的URL请求被一个PHP文件拦截,通常称为前端控制器(Front Controller) 这个PHP文件分析这个URL,获得一个执行控制器(Action Controller)的名字和一个执行方法(Action Method)转载 2010-07-09 19:45:00 · 842 阅读 · 0 评论 -
初探magento的MVC架构(Create new module “HelloWorld” – in Magento)
Do you want to create a new page in Magento ? or Do you want to create a new module in Magento ? If yes, Then ok, just spend 10 minutes and follow below steps.Objectives: I will create a new page in Magento whose output will be “Hello World ! I am a Magent转载 2010-07-09 19:44:00 · 1571 阅读 · 0 评论 -
Magento如何通过url参数给购物车添加商品?
<br />如题,如果是简单商品:<br />1.登录后台Catalog|Manage Products,查看对应商品的ID号,比如7<br /> <br />2.然后直接在地址栏输入 url<br />http://yourstoreurl/checkout/cart/add?product=[id]&qty=[qty]<br />或者<br />http://yourstoreurl/checkout/cart/add/product/[id]/qty/[qty]<br /> <br />如果I原创 2011-03-29 00:11:00 · 2324 阅读 · 4 评论 -
magento -- 修改文件来手动控制编译的开启和关闭
之前遇到一个情况,在编译开启的状态下安装了一个新插件,结果前后台都不能访问了,这时想去找找是哪里在控制编译的开启和关闭,先把编译关了来保证系统不报错。按照一般的习惯后台数据或配置都是存在于数据库,但找遍数据库也没发现跟编译有关的数据。因为编译的结果是在/includes/src目录下生产很多文件,去includes文件夹时发现了config.php文件,从命名就可以看出这是一个做配置的文件,经过拿转载 2011-06-30 13:10:00 · 861 阅读 · 0 评论 -
Magento 中使用AJAX异步提交数据(Using Ajax with Magento)
如果你想用ajax提交magento的表单数据,可以尝试这种写法getUrl('yourmoduleCompanyName/index/moduleIndexControllerAction') ?>', {asynchronous:true, evalScripts:fal原创 2011-10-14 13:54:36 · 2705 阅读 · 0 评论 -
关于获取Magento的最新订单
Magento模块开发的一般写法都是 Magento特有的MVC结构,如果你熟悉API或者想外部调用订单的信息,那么这篇文章可能会适合你凡是数据处理都会有个数据逻辑处理,所以首先获取订单对象 $showProductNum = 6; $orde原创 2011-09-22 01:23:45 · 2131 阅读 · 0 评论