
Magento开发专栏
讨论Magento的使用,模版制作,二次开发等等
ddjohn
coder
展开
-
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操作Cookie 并且使用观察者&事件来禁用单页面全页缓存(EE FPC)
Groupon(http://www.groupon.hk/)的首次访问会弹出一个框让客户输入电子邮件来订阅他们的最新咨询,只要提交表单或者点已经提交的按钮该框就会消失 并且以后访问都不会出现 大家应该见过 最近按照公司的要求需要在magento里面开发类似的效果。 首先明确这其中使用的原理是cookie 那magento该怎么操纵cookie呢 其实在core的model里面有一个cooki原创 2012-08-17 15:34:27 · 2723 阅读 · 0 评论 -
magento invalid backend model specified giftmessage entity attribute backend boolean config
由于给magento瘦身 我禁用调很多模块 包括sale payment giftmessage等等 留下cms和产品展示等相关模块 加上full page cache全页缓存模块 这样速度就飞快了 那么问题来了 其中有一个invalid backend model specified giftmessage entity attribute backend boolean config 这是和e翻译 2012-06-29 16:15:40 · 1485 阅读 · 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 评论 -
给Block输出的html设置缓存
Magento的缓存类型分好几种 其中一种是Block的html缓存 俗称静态化(非伪静态),理解Magento的缓存 得先了解它的模版体系 这里不多解析了。总而言之,Magento只能做基于Block的局部缓存,给这些Block做缓存其实很简单,默认情况下开启缓存的Block只是极少数,比如Footer是其中一个,毕竟footer需要更新数据的频率很低。 protected funct翻译 2012-06-21 16:47:05 · 1209 阅读 · 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结账时如何移除运费选择步骤(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 评论 -
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 评论 -
Warning: require_once(lib/Mage/Autoload/Simple.php)
Warning: require_once(lib/Mage/Autoload/Simple.php)...Fatal error: require_once() [function.require]: Failed opening required 'lib...以上这两个错误看起来有点莫名其妙,直接解释是找不到对应的类,就算是刚刚开始安装的也可能出现这样的错误。实际上,有的空间解压原创 2012-05-20 15:11:28 · 2092 阅读 · 0 评论 -
How to chage the default opstion value when adding new products?
1.statusapp/code/core/Mage/Catalog/Model/Product/Status.php注释掉157到160的代码/* array( 'value' => '', 'label' => Mage::helper('catalog')->__('-- Please Select --') )*/2.inventory库存状态默认为有库存打开文件/app/design/admin原创 2010-07-09 19:42:00 · 889 阅读 · 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
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 评论 -
后台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 评论 -
后台产品页显示产品缩略图的插件
Key:magento-community/TBT_Enhancedgrid-1.2转载 2010-07-20 10:58:00 · 916 阅读 · 0 评论 -
如何迁移你远程主机上的magento到本地主机安装
<br /><br />有几个方法来管理这一过程:*通过 使用SSH *通过 的FTP *自动 PHP的 (迁移Magento 自动化脚本)<br />在这里,我从我的远程主机迁移到我的XAMPP例如本地测试环境,因为我第一次安装在我的远程主机magento然后我想在我的发展速度和方便硬盘驱动器。 一些偏远的托管公司提供脚本安装,它是更快地安装它magento。<br />1。 始终创建数据库从magento骨干/管理面板“>系统”>工具“>备份>”创建备份转储,然后下载的“gz”点击转储文件。 保存在一个翻译 2010-08-02 13:50:00 · 1495 阅读 · 0 评论 -
关于currency显示的问题
<br />1.currency setup的设置<br />2.system ——manage currency rate的管理<br />3.cache原创 2010-10-01 09:52:00 · 1226 阅读 · 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 评论 -
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 评论 -
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 评论 -
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 评论 -
Magento 新闻模块开发教程 (一) 创建骨架目录
Magento 模块应当遵循 Magento的MVC结构,包括block,controllers,etc,helper,model,sql,视图层放在design的对应目录下,分为layout和template。当然在写模块之前,你必须创建模块的xml启动文件,这个我会在后续的章原创 2011-07-08 13:39:33 · 2078 阅读 · 0 评论 -
Magento 新闻模块开发教程 (二) 激活你的模块
上一章讲的是创建新闻模块必备的骨架,现在我们应该告诉Magento来激活这个模块。1. 在app / etc / modules中的应用程序创建一个新的XML文件,命名为INTERFACE_MODULE目录中。就我而言,这是Voodoo_News.xml2.原创 2011-07-08 13:47:59 · 1767 阅读 · 0 评论 -
Magento 新闻模块开发教程 (三) 创建前后端控制器
之前创建了骨架目录并且激活了新模块,现在要为模块创建前台和后台的控制器。1. 首先在app/code/local/Voodoo/News/controllers/ 中创建一个名为IndexController.php的前端控制器:class Voodoo_Ne原创 2011-07-08 14:43:03 · 2496 阅读 · 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 新闻模块开发教程 (五) 创建辅助类
在MVC应用程序中,模型处理业务逻辑和数据返回到控制器,控制器最终传递数据给视图。如果我们需要一个相当复杂的需求逻辑需要重复或我们不希望它放置在一个视图文件,Helper组件将有助于处理复杂的情况。在大多数情况下,一个辅助类帮助组织一个像样的数据逻辑,可以用他来反复处理。在我们这原创 2011-07-08 15:24:58 · 1475 阅读 · 0 评论 -
Magento 新闻模块开发教程 (六) 创建模型
创建好辅助类后,接下来为我们的新闻模块创建相关的模型。在MVC结构中,Model (模型)用于处理业务逻辑,在Magento中,原创 2011-07-08 15:52:04 · 2238 阅读 · 1 评论 -
Magento 新闻模块开发教程 (七) 建立模块的SQL
在这里一章中,我们将创建一个php文件,这将在magento的database中创建一个新表。在app/code/local/Voodoo/News/sql/news_setup/目录下创建一个mysql4-install-0.1.0.php文件:<?php $installer = $this; $installer->startSetup(); $installer->run原创 2011-07-08 16:33:42 · 1465 阅读 · 0 评论 -
Magento 新闻模块开发教程 (八) 建立模板文件
在创建好控制器和模型等后,自然会想到应该创建视图文件。在app\design\frontend\default\default\template\news目录下创建news.phtml__('Latest news from Voodoo') ?> getNewsList(原创 2011-07-08 16:40:59 · 2022 阅读 · 2 评论 -
Magento 新闻模块开发教程 (九) 建立Block
前面八章中我们已经先后建立了文件骨架,激活文件,前后端控制器,配置文件,辅助类,模型,SQL,模板,新闻模块开发的最后一步是创建block在app\code\local\Voodoo\News\Block中创建News.php文件:<?phpclass Voodoo_News_原创 2011-07-08 17:08:46 · 2013 阅读 · 0 评论 -
Magento前台只有产品的缩略图不显示?
最近发现一个怪异的现象,Magento前台只有产品的缩略图不显示。我检查了之前的操作,后台产品图片的选择设置,media文件夹的权限,缓存等一系列可能引发的因素,发现缩略图还是不显示,那就奇怪了,其他服务器上包括本地都是没问题的。缩略图通常是保存在media下类似这样的路径med原创 2011-07-31 12:59:01 · 2532 阅读 · 2 评论 -
外部Magento代码操作数据库
如何在外部操纵Magento的数据库,首先我们必须取得外部运行的handle/* external run Magento */require_once('app/Mage.php');umask(0);Mage::app('default'); //blank//M原创 2011-09-15 12:11:07 · 1371 阅读 · 0 评论 -
关于获取Magento的最新订单
Magento模块开发的一般写法都是 Magento特有的MVC结构,如果你熟悉API或者想外部调用订单的信息,那么这篇文章可能会适合你凡是数据处理都会有个数据逻辑处理,所以首先获取订单对象 $showProductNum = 6; $orde原创 2011-09-22 01:23:45 · 2131 阅读 · 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 如何在产品页获取当前产品的销量
已经可以在自定义的bestseller模块下获取销量,bestseller模块可以直接引用数组中ordered_qty的值$_product->ordered_qty;如果是在产品页面就比较麻烦,我们必须获取reports/product_collection这个资源类的实例,然后再进行筛选。写法各不相同、$reportCollection = Mage::getResourceModel原创 2011-11-19 16:39:59 · 1751 阅读 · 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 如何获取一个产品资源集合?
$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外部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 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 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 评论