• magento server configured incorrectly配置错误解决笔记

    环境 Apache 2.2.15  mysql5.5.15  php 5.3.2  magento 1.6.0.0

    安装完成后登录magento后台,提示信息

    Your web server is configured incorrectly. As a result, configuration files with sensitive information are accessible from the outside. Please contact your hosting provider.

    网上搜索一番后,大概就是跟app/etc/local.xml 的访问权限有关

    浏览器中输入  http://site url/app/etc/local.xml 发现确实可以直接访问,这样magento的重要数据信息就直接曝露了,问题后果很严重…

    考虑修改 app/etc/  目录权限,但是会导致整站无法正常访问,检查 app 目录下的 .htaccess 文件   发现 Deny from all   但是为什么没有起作用呢。

    再查 发现是跟 Apache 配置有关
    Alias /mag16 “/data/www/mag16″

    <Directory “/data/www/mag16″>
    Order allow,deny
    Allow from all
    </Directory>

    向Directory中添加
    AllowOverride All

    后  保存配置, service httpd restart

    刷新后台,警告不再出现!
    url访问  app/etc/local.xml   提示 403错误
    You don’t have permission to access /mag16/app/etc/local.xml on this server

    问题解决,记此以作备忘 :-)

  • Function set_magic_quotes_runtime() is deprecated 问题笔记

    最近看一个轻量级的框架CI由于习惯性的依赖中文资料,所以用的是v1.5.3

    简单的安装后 访问 出现提示 Function set_magic_quotes_runtime() is deprecated

    上网搜一下,发现原因 php 5.3以上的版本废弃了 set_magic_quotes_runtime()

    解决方法:

    根据错误提示信息,找到
    set_magic_quotes_runtime(0);
    替换为:
    ini_set(“magic_quotes_runtime”, 0);

    即可。

    了解了下其作用,不太清楚  记录一下备忘

    在php.ini的配置文件中,有个布尔值的设置,就是magic_quotes_runtime,当它打开时,php的大部分函数自动的给从外部引入的(包括数据库或者文件)数据中的溢出字符加上反斜线。

    当然如果重复给溢出字符加反斜线,那么字符串中就会有多个反斜线,所以这时就要用set_magic_quotes_runtime()与 get_magic_quotes_runtime()设置和检测php.ini文件中magic_quotes_runtime状态。

    为了使自己的程序不管服务器是什么设置都能正常执行。可以在程序开始用get_magic_quotes_runtime检测设置状态秋决定是否要手工处理,或者在开始(或不需要自动转义的时候)用set_magic_quotes_runtime(0)关掉。

    magic_quotes_gpc设置是否自动为GPC(get,post,cookie)传来的数据中的’”\加上反斜线。可以用 get_magic_quotes_gpc()检测系统设置。如果没有打开这项设置,可以使用addslashes()函数添加,它的功能就是给数据库查 询语句等的需要在某些字符前加上了反斜线。这些字符是单引号(’)、双引号(”)、反斜线(\)与 NUL(NULL 字符)

  • 给magento产品分类添加自定义属性

    通过数据库给分类添加自定义属性, 以 Short Description 为例,

    简单记录如下 (entity_type_id 对应为 catalog_category,详细请参考数据库中其他分类属性的设置)

    INSERT INTO `eav_attribute` (
    `attribute_id` ,
    `entity_type_id` ,
    `attribute_code` ,
    `attribute_model` ,
    `backend_model` ,
    `backend_type` ,
    `backend_table` ,
    `frontend_model` ,
    `frontend_input` ,
    `frontend_label` ,
    `frontend_class` ,
    `source_model` ,
    `is_required` ,
    `is_user_defined` ,
    `default_value` ,
    `is_unique` ,
    `note`
    )
    VALUES (
    NULL , '3', 'short_description', NULL , NULL , 'text', NULL , NULL ,
     'textarea', 'Short Description', NULL , NULL , '0', '0', NULL , '0', ''
    );

    插入后生成新属性id  121

    INSERT INTO `eav_entity_attribute` (
    `entity_attribute_id` ,
    `entity_type_id` ,
    `attribute_set_id` ,
    `attribute_group_id` ,
    `attribute_id` ,
    `sort_order`
    )
    VALUES (
    NULL , '3', '3', '3', '121', '4'
    );

    仍然使用第一个表生成的id 121

    INSERT INTO `catalog_eav_attribute` (
    `attribute_id` ,
    `frontend_input_renderer` ,
    `is_global` ,
    `is_visible` ,
    `is_searchable` ,
    `is_filterable` ,
    `is_comparable` ,
    `is_visible_on_front` ,
    `is_html_allowed_on_front` ,
    `is_used_for_price_rules` ,
    `is_filterable_in_search` ,
    `used_in_product_listing` ,
    `used_for_sort_by` ,
    `is_configurable` ,
    `apply_to` ,
    `is_visible_in_advanced_search` ,
    `position` ,
    `is_wysiwyg_enabled` ,
    `is_used_for_promo_rules`
    )
    VALUES (
    '121', NULL , '0', '1', '1', '0', '0', '0', '0', '1', '0', '0', '0', '1', '',
     '0', '1', '1', '0'
    );

    调用方法 catalog/category/view.phtml 中

    <?php echo $_category->getData('short_description');  ?>
  • Magento calendar IE8 js位置控制问题

    环境:magento 1.5.1

    IE8下 magento的日期表格的位置 js计算错误,导致样式异常

    解决记录,修改 /js/calendar/calendar.js   1459行左右


    br.y += document.body.scrollTop;
    br.x += document.body.scrollLeft;

    修改为
    br.y += document.body.document.documentElement.scrollTop;
    br.x += document.body.document.documentElement.scrollLeft;

    即:

    if (Calendar.is_ie) {
    /* old non working
    br.y += document.body.scrollTop;
    br.x += document.body.scrollLeft; */
    br.y += document.body.document.documentElement.scrollTop;
    br.x += document.body.document.documentElement.scrollLeft;

     

    刷新即可,记此备忘

    参考链接:magentocommerce.com/boards/viewthread/50895/

  • magento 边栏添加 popular search块

    Magento 默认的已经有popular search的内容了,位于底部的 search terms 链接结果页面中,所以要实现 在边栏显示 popular search块只需要在对应的位置调出相应的内容即可。

    修改xml文件(一般是 catalog.xml)在对应位置添加以下调用代码
    <block type=”catalogsearch/term” name=”sidebar.seo.searchterm” template=”catalogsearch/sideterm.phtml”/>

    进入template/catalogsearch/目录 拷贝term.phtml 文件为sideterm.phtml
    方便我们修改边栏样式,而不会影响到默认的调用

     

    经常在网站使用一段时间之后,搜索的内容细则较多,这样就使边栏调用出来的popular search 过长,影响页面美观。 这时我们再次通过对sideterm.phtml进行简单的修改,来缩减边栏显示的热门搜索条目,

    <?php

    $t_limit = 0.4;

    foreach ($this->getTerms() as $_term):

    if($_term->getRatio() > $t_limit) :

    ?>

    ….

    <?php

    endif;

    endforeach;

    ?>

    ($t_limit 越大 显示的条目越少,取值范围0~1 ,参考了默认显示中控制字体大小的代码片段)

    且记如此,有更好的方法 或 意见建议 欢迎留言 :-)

click
©2010-2024 Jeen All Rights Reserved.Powered by emlog 京ICP备15058100号-1