0

我需要创建基于 CommerceTools 的商店的站点地图文件,如果它可以从 CTP 数据库的内容自动完成,那就太好了。

您是否知道是否已经开发了允许此任务的模块、工具或扩展?

编辑->


我知道每个在线商店都可以使用不同的技术构建。在我们的具体案例中,前端基于 Sunrise for JVM,因此为该技术创建此工具会很方便,尽管它不是必需的。

我还认识到,每个项目都可以具有使其与其他项目不同的特定功能(主要是静态内容或来自外部 CMS),因此我理解创建通用工具非常复杂。

无论如何,我认为拥有一些能够使用类别和产品的slug从CTP的最动态内容创建“sitemap-products.xml”的工具会很棒。

然后这个“sitemap-products.xml”可以从一个站点地图索引中调用,你可以从这个站点地图索引中链接这个和其他可以由CMS自行生成的辅助站点地图(如果你有的话)和/或其他更多可以创建的静态并由开发团队手动维护。


<-编辑

提前致谢。

4

3 回答 3

2

我会给你一个从数据库创建完美站点地图的简单规则。

站点地图.php:

<?php
$site = "https://yourdomain.ccom/"; // your URL addres with slash at end "/".
$chfreqprod = "weekly"; // the frequency of sitemaps
$priority = "0.8";      // priority
$date = date("Y-m-d\TH:m:s+02:00", time());
define ('DB_USER', 'changeWithYourUser');
define ('DB_PASSWORD', 'changeWithYourPassword');
define ('DB_HOST', 'localhost');
define ('DB_NAME', 'cangeWithYourDataBase');
$conn = mysql_connect(DB_HOST, DB_USER, DB_PASSWORD) or die("Could not connect to the database."); 
        mysql_select_db(DB_NAME, $conn) or die("Can not select the table in the database!");  
        header("Content-Type: text/xml;charset=utf-8");
echo "<?xml version=\"1.0\" encoding=\"UTF-8\"?>
<?xml-stylesheet type=\"text/xsl\" href=\"smap.xsl\"?>
<urlset xmlns=\"http://www.sitemaps.org/schemas/sitemap/0.9\">";
$query = @mysql_query("SELECT * FROM products LIMIT 0,25000");
while($row = @mysql_fetch_array($query)){
$product = $row['product_seo'];
echo "<url>
     <loc>".$site.$product.".html</loc>
     <lastmod>".$date."</lastmod>
     <changefreq>".$chfreqprod."</changefreq>     
     <priority>".$priority."</priority>
     </url>";
}
echo "</urlset>";
?>

smap.xsl:

<?xml version="1.0" encoding="UTF-8"?>
<xsl:stylesheet version="1.0" 
                xmlns:html="http://www.w3.org/TR/REC-html40"
                xmlns:sitemap="http://www.sitemaps.org/schemas/sitemap/0.9"
                xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
    <xsl:output method="html" version="1.0" encoding="UTF-8" indent="yes" />
    <xsl:template match="/">
        <html xmlns="http://www.w3.org/1999/xhtml">
            <head>
                <title>XML Sitemap</title>
                <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
                <meta name="robots" content="noindex,follow" />
<style type="text/css">
body {
    font-family:"Lucida Grande","Lucida Sans Unicode",Tahoma,Verdana;
    font-size:13px;
}
#intro {
    background-color:#CFEBF7;
    border:1px #2580B2 solid;
    padding:5px 13px 5px 13px;
    margin:10px;
}
#intro p {
    line-height:16.8667px;
}
#intro strong {
    font-weight:normal;
}
table {
    width:100%;
    }
td {
    font-size:11px;
}
th {
    text-align:left;
    padding-right:30px;
    font-size:11px;
    background-color:#E1E3EE;
}
tr.high {
    background-color:whitesmoke;
}
tr:hover {
    background-color:#E8EAF2;
}
#footer {
    width:100%;
    padding:2px;
    margin-top:10px;
    font-size:8pt;
    color:gray;
    text-align:center;
}
#footer a {
    color:gray;
}
a {
    color:#000;
    text-decoration:none;
}
a:hover {
    text-decoration:underline;
}
</style>
</head>
<body>
<xsl:apply-templates></xsl:apply-templates>
</body>
</html>
</xsl:template>

<xsl:template match="sitemap:urlset">
<h1 align="center">XML Sitemap</h1>

        <div id="content">
            <table cellpadding="5">
                <tr style="border-bottom:1px black solid;">
                    <th width="70%">URL</th>
                    <th width="5%">Priority</th>
                    <th width="12%">Change frequency</th>
                    <th width="13%">Last modified</th>
                </tr>
                <xsl:variable name="lower" select="'abcdefghijklmnopqrstuvwxyz'"/>
                <xsl:variable name="upper" select="'ABCDEFGHIJKLMNOPQRSTUVWXYZ'"/>
                <xsl:for-each select="./sitemap:url">
                    <tr>
                        <xsl:if test="position() mod 2 != 1">
                            <xsl:attribute  name="class">high</xsl:attribute>
                        </xsl:if>
                        <td>
                            <xsl:variable name="itemURL">
                                <xsl:value-of select="sitemap:loc"/>
                            </xsl:variable>
                            <a href="{$itemURL}">
                                <xsl:value-of select="sitemap:loc"/>
                            </a>
                        </td>
                        <td>
                            <xsl:value-of select="concat(sitemap:priority*100,'%')"/>
                        </td>
                        <td>
                            <xsl:value-of select="concat(translate(substring(sitemap:changefreq, 1, 1),concat($lower, $upper),concat($upper, $lower)),substring(sitemap:changefreq, 2))"/>
                        </td>
                        <td>
                            <xsl:value-of select="concat(substring(sitemap:lastmod,0,11),concat(' ', substring(sitemap:lastmod,12,5)))"/>
                        </td>
                    </tr>
                </xsl:for-each>
            </table>
        </div>
        <div id="footer">Index Sitemap by <a href="https://www.adydev.com" target="_blank">www.adydev.com</a></div>
    </xsl:template> 

<xsl:template match="sitemap:sitemapindex">
<h1 align="center">XML Sitemap Index</h1>

<div id="content">
<table cellpadding="5">
    <tr style="border-bottom:1px black solid;">
        <th width="85%">URL of sub-sitemap</th>                
        <th width="15%">Last modified</th>
    </tr>
<xsl:for-each select="./sitemap:sitemap">
    <tr>
<xsl:if test="position() mod 2 != 1">
<xsl:attribute  name="class">high</xsl:attribute>
</xsl:if>
        <td>
<xsl:variable name="itemURL">
<xsl:value-of select="sitemap:loc"/>
</xsl:variable>
<a href="{$itemURL}">
<xsl:value-of select="sitemap:loc"/>
</a>
        </td> 
        <td>
<xsl:value-of select="concat(substring(sitemap:lastmod,0,11),concat(' ', substring(sitemap:lastmod,12,5)))"/>
        </td>
    </tr>
</xsl:for-each>
</table>
</div>
<div id="footer">Index Sitemap by <a href="https://www.adydev.com" target="_blank">www.adydev.com</a></div>
</xsl:template>
</xsl:stylesheet>

.htaccess:

RewriteRule ^sitemap.xml$ sitemap.php [L]

对于多语言站点地图、索引站点地图和自动化站点地图,请与我联系。谢谢!

于 2018-03-08T03:36:03.833 回答
1

我回到这个问题告诉你,我们终于设法通过使用 Play Framework 的模块来解决我们的需求,该模块能够使用你传递的 URL 生成站点地图。

我们已经从其创建者的存储库(https://github.com/edulify/play-sitemap-module.edulify.com)下载了该模块,并且在为产品、类别和静态页面配置了一些不同的提供程序之后,因为我们想要每种类型的链接都有不同的搜索引擎刷新频率和优先级,我们设法每 24 小时自动生成我们的 sitemap.xml。

如果有人需要帮助在您的商店中使用 Sunrise 实现此功能,请与我联系,我会尽力帮助您。

非常感谢大家试图帮助我们。问候。米格尔

于 2018-09-24T15:49:44.127 回答
1

没有可用的标准模块或扩展;站点地图是特定于前端的,因为每个人在站点上都有不同的 URL 模式和非商业内容。需要根据您的项目开发的前端技术构建站点地图。

于 2018-03-08T09:35:03.810 回答