手机浏览 RSS 2.0 订阅 膘叔的简单人生 , 腾讯云RDS购买 | 超便宜的Vultr , 注册 | 登陆
浏览模式: 标准 | 列表2024年09月的文章

Magento 中为FORM添加自定义的判断

 搜索了一些网上的教程,发现网上对于自定义的判断,都是说加个字段或者基于prototype来进行判断就可以了。什么require-text代表必填 之类的。这段时间在对magento做处理的时候发现这样的判断好痛苦(好象,我是指基于产品的FORM的扩展),如果是自己做二次开发,自己写表单,当然这样就OK了

翻看了一下程序,我开始看到资料就是指require-text之类的扩展,那我想,我只要能够加入一个class属性,我就可以基于这个class属性进行判断了,不是吗?

于是我找到了模版的layout,重新定义了layout,表示我可以引入一个指定的js文件,或者引入了代码。

然后,我找到了dispatchEvent,发现有一个事件,但我看了下,在这个事件里我几乎没有什么事情可以做【不过,基于这个事件,我把SKU,日期等做成了自动生成,只是他对表单的验证并没有什么帮助】

找了半天,最后发现数据库有一个backend_model,原来可以为这些程序指定事件,发现SKU有一个事情,是判断 sku的长度不能超过N个字符的,于是对着这个model进行了测试,发现果然OK。添加了几个model,然后update一下数据库,一切就完成了

 

Tags: magento

Magento 中 后台 tag save的时候的BUG

magento的后台中在tag进行保存的时候做了一次处理,它原先的代码是:

PHP代码
  1. if (isset($postData['tag_assigned_products']) ) {  

 意思是如果form提交的时候,有tag_assigned_products字段的话,会进行处理。然而,如果你当时的tag是inactive的时候,在tag of administrator的列表 中是看不到有tag的。这个时候你点保存。那么原来那些tagof administrator的tag就会全部被删除 了。怎么办?

只要你点击那个状态条,看到列表的时候,这个字段就有值了。这时候只有两种处理方式:

1、刷新页面重做处理

2、修改程序。

所以我改成了:

PHP代码
  1. if (isset($postData['tag_assigned_products']) && $postData['tag_assigned_products']) {  

OK,收工

 

迁移VPS

从有这个博客开始,我的博客迁移了最少有7次之久,从自有服务器在上海机房,迁到江苏机房(只换IP,还好)

然后迁移到linode,然后迁移到budgetVPS,然后迁移budgetVM,然后迁移到linode,再迁移到99vps。
 
每次迁移都是一件头疼的事情。99vps因为更换机房,我又重迁了一次。细算一下。居然有8次了。。
累啊
 
所幸这次迁移是最轻松的。可能是因为迁移多了,经验丰富了吧。哈哈
 
--测试上传:
大小: 74.74 K
尺寸: 500 x 301
浏览: 1462 次
点击打开新窗口浏览全图

Add tags when creating product in Magento?

A) to add tags directly when entering/editing a product, you will need an extension, such as this one. This method is most useful to let people with less magento experience create tags (such as data entry people).

B) To add tags without leaving the administrator (not going to the frontend). This is useful for applying the same tag to multiple products:

Create tags through Catalog->All Tags-> Add New Tag button.

After creating the tags, click on each tag. You’ll see a detailed set of options to “Edit Tag”.

Go to the “Products tagged as administrator” tab, click on ‘Reset Filter” . You see all your products getting listed.

Select the products to which you want to assign the tag & click on “Save Tag”.

C) To add tags via the frontend & the backend, which is useful when you want to add a lot of tags to each single product:

Just create your products as normal. When you are ready to add tags to your products just create yourself a customer account for your store and go to each product and add them as a customer would. I wrote out all of my tags in a text editor. Now since I am using phrases, and not just words, my tags will be entered as:

‘Stylus C64’ ‘Stylus C66’ ‘Stylus C84’ ‘Stylus C84N’ ‘Stylus C84WN’ ‘Stylus C86’ ‘Stylus CX3600’ ‘Stylus CX3650’ ‘Stylus CX4600’ ‘Stylus CX6400’ ‘Stylus CX6600’

Take note that you need the single quote (’) to bracket your phrases… or just spaces between each word if your tags are single words. Very easy to write out and then copy/paste into the Add Your Tags section of each product.

Once you copy/paste your tags in the front-end you will be prompted with a message that they must be approved from the admin/moderator. Now log into the back-end and go to the tags section (Catalog > Tags > Pending Tags). There you will see the list of tags you just submitted from the front-end of the site. Now just click “Select All”, then from the Actions drop-down menu choose “Change Status”, and then from the status drop-down choose “Approved” and then “Submit”.

Now you can pick a method most appropriate for each type of use!

http://stackoverflow.com/questions/9261935/add-tags-when-creating-product-in-magento

Tags: magento

magento 中处理 catalog_product_prepare_save 行为

 最近在做magento二次开发,遇到个问题,即,我要针对商品的数据中的某些数据做二次处理。看了一下代码,发现在initProduct前有一个event事件:catalog_product_prepare_save,所以我想我只要覆盖这个方法就OK了。网上找了些资料,发现如果再绑定一个event则多个Event都会执行。于是,我就按照这个思路在config.xml里加入了events事件。

然后在Model下面加了Observer.php来监听事件。为了测试系统自有的event能够工作,我在系统默认的event里做了一下输出,发现确实有变化 了。所以证明我的思路还是正确的。当然,这也借鉴了网上的一些资料

config.xml里加入:

XML/HTML代码
  1. <adminhtml>  
  2.     <events>  
  3.         <catalog_product_prepare_save>  
  4.             <observers>  
  5.                 <xxx_web_observer>  
  6.                     <type>singleton</type>  
  7.                     <class>Xxx_Web_Model_Observer</class>  
  8.                     <method>prepareProductAuthor</method>  
  9.                 </xxx_web_observer>  
  10.             </observers>  
  11.         </catalog_product_prepare_save>  
  12.     </events>  
  13. </adminhtml>  

本来我class想写成xxxx/observer的,但死活通不过,我不知道是我写错了。还是。。最后写成详细的类名才OK。(也可能是因为不在系统目录下,而在local目录下的原因吧?)

Observer就不写了。参考core/mage/bundle/model/observer.php即可(本来有大小写的,我忽略了)