国际电子商务技术 & Magento开发公司

Maishen technologies

Welcome visitor! You canlogin orcreate an account.

热线:+86-0532-58973093

麦神科技有限公司
Mygod Technologies

官方认证开发工程师

如何把自己制作的扩展页面写入magento的sitemap对应的sitemap.xml中

2012年7月31日星期二 Asia/Shanghai下午5:54:27

对于magento,有不少url是没有加入到sitemap中的,譬如tag,如果我们把tag的url重写成tag/tagname的样子,我们在后台生成sitemap的时候想要把重写后的tagurl加入,就要重写magento的sitemap生成机制了!

下面是步骤:

1.在模块对应的config.xml中的model标签中加入代码:

  <sitemap>
                <rewrite>
                    <sitemap>yourpackagename_exname_Model_Sitemap</sitemap>
                </rewrite>
            </sitemap>

然后这个文件继承extends Mage_Sitemap_Model_Sitemap
下面是写入tag的代码

 /**
         * Generate tag pages sitemap
         */
        $changefreq = (string)Mage::getStoreConfig('sitemap/page/changefreq');
        $priority   = (string)Mage::getStoreConfig('sitemap/page/priority');
        $tags = Mage::getModel('tag/tag')->getPopularCollection()
                ->joinFields(Mage::app()->getStore()->getId())
                
                ->load()
                ->getItems();

        foreach ($tags as $item) {
            $tagname = $item->getName();
            $tagname = str_replace("-","--",$tagname);
            $tagname = str_replace(" ","-",$tagname);

            $xml = sprintf('<url><loc>%s</loc><lastmod>%s</lastmod><changefreq>%s</changefreq><priority>%.1f</priority></url>',
                htmlspecialchars($baseUrl."tag/".$tagname),
                $date,
                $changefreq,
                $priority
            );
            $this->sitemapFileAddLine($xml);
        }
        unset($tags);

然后在后台重新生成,就可以看到tag的url了!

0 Comments | Posted in magento二次开发 By terry water

修改magento中table表的前缀

2012年7月26日星期四 Asia/Shanghai上午11:30:26

默认的安装是不带有前缀的,有的时候我们很多数据库想安装在一个数据库表中,那么就要通过前缀进行区分,然后我们可以一个数据库安装很多magento网站,下面是magento安装完毕后,修改表的前缀的方法:

1.新建一个文件prifix.php

2.加入内容:

<?php
$database_host = "localhost";
$database_user = "root";
$database_password = "root";
$magento_database = "magento2";
$table_prefix = "dwz_";
$db = mysql_connect($database_host, $database_user, $database_password);
mysql_select_db($magento_database);
$query = "SHOW TABLES";
$result = mysql_query($query) or die('Err');
while($row = mysql_fetch_array($result)) {
    $old_table = $row[0];
    if(preg_match('/'.$table_prefix.'/', $old_table)) {
        echo "Table $old_table already done<br/>\n";
        continue;
    }
 
    $new_table = $table_prefix.$old_table;
    echo "Renaming $old_table to $new_table<br/>\n";
    $query = "RENAME TABLE `$old_table`  TO `$new_table`";
    mysql_query($query);
}
~~~~~~~~~~~~~~~~~~~~~~~·
说明:
$database_host
= "localhost"; $database_user = "root";//数据库用户 $database_password = "";//数据库的密码 $magento_database = "magento2";//数据库的名字 $table_prefix = "dwz_"; //表的前缀
填写完成后运行代码
然后到文件app/etc/local.xml中
<table_prefix><![CDATA[]]></table_prefix>
改为
<table_prefix><![CDATA[dwz_]]></table_prefix>

OK,搞定!完毕!table表的前缀批量修改完成,您可以一个数据库中安装很多系统了!

0 Comments | Posted By terry water

给magento网站添加收藏按钮

2012年7月24日星期二 Asia/Shanghai下午5:01:13

给magento添加添加到收藏夹的按钮的代码如下:

 

<script language="javascript">
function addfavor(url,title) {
if(confirm("website:"+title+"\nUrl:"+url+"\n Determine?")){
var ua = navigator.userAgent.toLowerCase();
if(ua.indexOf("msie 8")>-1){
external.AddToFavoritesBar(url,title,'');//IE8
}else{
try {
window.external.addFavorite(url, title);
} catch(e) {
try {
window.sidebar.addPanel(title, url, "");//firefox
} catch(e) {
alert("error");
}
}
}
}
return false;
}
</script>

<a href="javascript:;" onclick="javascript:addfavor('http://www.magentouse.com','');">add to Favorite</a>

0 Comments | Posted By terry water

magento 在线聊天工具

2012年7月24日星期二 Asia/Shanghai上午9:16:47

1

聊天工具的安装

现在很多聊天工具都是免费30天,然后收费的,免费的,用的好的很少

下面是一款我们感觉很不错的聊天工具,zopim livechat

2

使用

登录网址:www.zopim.com

注册账号。完成后登录。

登录成功后点击dashboard

 

进入后,点击右侧的setting

 

3

复制这里的代码

 

复制出来,然后到magento网站找到文件

App/design/frontend/your package/your template/template/page/html/footer.phtml文件

在文件的底部把这个代码复制进去,刷新缓存即可!

这个聊天工具的各个版本的差别如下:

 

天下没有免费的午餐,都是为了让我们消费,人家才提供服务器免费使用,呵呵

0 Comments | Posted in magento日常所用 By terry water

js操作--指向页面的某个div

2012年7月21日星期六 Asia/Shanghai下午5:55:01

在操作的过程中,多个tab,我们需要使用显示和隐藏,在同一个div中显示不同的内容,如果使用.....html#sc6,点击指向某个div是不可以的,我们需要用css操作指向!

下面是一段代码

 

document.getElementById(cid).className="display_div";

redirTime = "0";
redirURL = "#sc7";
self.setTimeout("self.location.href = redirURL;",redirTime);

也就是先改变class,让其显示,然后使用显示,然后执行指向函数!

OK!

0 Comments | Posted By terry water
 
  • Mygod Technologies
  • 麦神科技有限公司
  • 香港中路8号
  • 中铁青岛中心大厦A3001
  • 市南区, 青岛, 266000
  • 电话: 0532-5897-3093

订阅我们的最新消息。

我们将严格尊重您的隐私。

关注我们的微信
获取外贸电子商务最新资讯;跨境推广最新策略;电子商务网站技术最新趋势。

2018 Mygod Technologies. 保留所有权. Privacy Policy