Monthly Archives: 五月 2016

Create a Country Drop Down in the Frontend of Magento

Create a Country Drop Down in the Frontend of Magento

Add the following code to any template file in the frontend of Magento and you will get a drop down box using the country name as the label and the country code as the value.

<?php $_countries = Mage::getResourceModel('directory/country_collection') ->loadData() ->toOptionArray(false) ?><?php if (count($_countries) > 0): ?> <select name="country" id="country"> <option value="">-- Please Select --</option> <?php foreach($_countries as $_country): ?> <option value="<?php echo $_country['value'] ?>"> <?php echo $_country['label'] ?> </option> <?php endforeach; ?> </select><?php endif; ?>

Create a Country Drop Down in the Magento Admin

When creating forms in the Magento Admin area, it is very rare that we use actual HTML. The reason for this is that forms are generally built using pre-built functions. The benefit of this is that each Admin page looks uniform and helps to keep Magento looking like one whole application rather than having loads of bits stuck onto it. As our method of adding HTML changes, so must our method of creating our country drop down.

<?php
        $fieldset->addField(‘country’, ‘select’, array(
                ‘name’    => ‘country’,
                ‘label’   => ‘Country’,
                ‘values’  => Mage::getModel(‘adminhtml/system_config_source_country’)->toOptionArray(), 
        ));
?>

服务器给SSH暴力攻击~~~

        在2016年5月21日,公司服务器的网络outl流量达到了200MB/S~~~~~查看日志记录    /bin/awk ‘/Failed/’ /var/log/secure  | tail -n 35    发现有人在暴力破解ssh账号中~~~~首先修改ssh端口,然后再网上找一个防ssh暴力破解的脚本(主要原理是错误登陆多少次就封这Ip访问)~

          虽然一开始给搞点有得郁闷,~~~应该以为是给ddos攻击那种~~~~没想到现在还有暴力破解ssh这么原始的方式存在~~~~真是暴力美学啊·~~~~~~不过人生第一次处理攻击,给攻击还是有点小激动的·~~~~~

一个人做技术很孤独

       来到了新公司,一直找不到PHP程序员,特别是magento方面,搞到什么都要自己来做~~~服务器也要做,优化也要做,开发也要做,网络也要做,前端也要做,API也要做,BUG也要做,面试也是做,管理也要做~~~~真的是一个人顶着N个人的活~~然后发现其实有团队蛮好,可惜只有一个PHP~~~突然发现之前N个程序员的日子真的能学习到好多东西~~~虽然那时候也是累,但是不想现在这样子的孤独啊~

        之前都同事都在一个公司,真想念他们·~~~~不知道以后会遇到怎样的同事和人~~~

Magento修改分类Grid的产品数量

一个BLock模块是使用了catelog_product_list的type,自动就默认后台catelog的Products per Page on Grid Default Value的值~~想修改,

就打算在后台Custom Design的Custom Layout Update设置

<reference name="product_list_toolbar">
  <action method="addPagerLimit"><limit>20</limit></action>
  <!--action method="setDefaultGridPerPage"><limit>20</limit></action-->
  <!--action method="setDefaultListPerPage"><limit>20</limit></action-->
</reference>

等等方法都行,后来不得不用最不想用的办法在模板里面

  $_productCollection = Mage::getModel('catalog/category')->load(254)
        ->getProductCollection()
        ->addAttributeToSelect('*')
        ->addAttributeToFilter('status', 1)
        ->addAttributeToFilter('visibility', 4)
        ->setPageSize(15);

$(window),scroll(function(){})失效

$(window),scroll(function(){})是首页时候,滚动到一定距离就失效,没这事件了·~~

百思不得其解

试着到$(window)改为$(document)就可以了~~

百思不得其解·~~

magento 优化

1.就是redis的安装
2.图片lazyload的安装
3.PHP APC安装(待测试)
4.系统原生的js和css合并,同时注意开启gzip,js没压缩,有可能是gizp_type,没有application/javascript

5.关闭无用模块,除了后台关闭,也要在modules文件夹中配置的xml也要false掉

哎·~~新公司忙,忙不自己网站都没时间处理了·~~~等我有空,我在给网站你看看~~~