如何在magento中使用元标记关键字作为网址?

时间:2013-04-08 05:45:58

标签: magento meta-tags

在我的magento商店中,需要在侧栏中将元标记实施为网址

我的商店里有两种类别。命名为X和Y。

我需要得到这种结果。

  • X - >类别 X

    -x1 -x2 -x3

- > Catogery X 关键字必须为url

  • Y - >类别 Y

    -y1 -Y2 -Y 3

- > Catogery Y 关键字必须为url

帮我解决这个问题。

现在我正在使用此代码

<div class="right-tab-middle">

<?php $_helper = Mage::helper('catalog/category') ?>

<?php $_categories = $_helper->getStoreCategories() ?>

<?php $currentCategory = Mage::registry('current_category') ?>

<?php if (count($_categories) > 0): ?>

<ul style="overflow:hidden;">

<div style="color:#BE0171;text-decoration:underline; font-size:16px; font-weight:bold;">Shop by:</div>

<!--    <?php foreach($_categories as $_category): ?>

<li style="margin:10px 0px; ">                                                  

<a style="color:#BE0171; text-decoration:none;" href="<?php echo $_helper->getCategoryUrl($_category) ?>">

<?php echo $_category->getName() ?>

</a>

<?php $_category = Mage::getModel('catalog/category')->load($_category->getId()) ?>
<?php $_subcategories = $_category->getChildrenCategories() ?>

<?php if (count($_subcategories) > 0): ?>

<ul>

<?php foreach($_subcategories as $_subcategory): ?>

<li style="margin:5px 0px 5px 10px; ">

<a style="color:#BE0171; text-decoration:none;" href="<?php echo $_helper->getCategoryUrl($_subcategory) ?>">

<?php echo $_subcategory->getName() ?><br />

</a>

</li>

<?php endforeach; ?>

</ul>

<?php endif; ?>

</li>

<?php endforeach; ?> -->

<?php 
$connection = Mage::getSingleton('core/resource')->getConnection('core_read');
$sql        = "SELECT GROUP_CONCAT( value SEPARATOR ' ' ) as keywords FROM mag_catalog_product_entity_text WHERE attribute_id=(SELECT attribute_id FROM mag_eav_attribute WHERE attribute_code='meta_keyword')" ;
$rows       = $connection->fetchAll($sql);

$metaKeywords = $rows[0]['keywords'];

//strip white space and replace with _
$str = preg_replace('/\s+/', ' ',$metaKeywords);
//$str = str_replace(' ','*',$metaKeywords);

$arr = explode(" ", $str);
$arr = array_count_values($arr);
arsort($arr);

$i = 0;


foreach($arr as $data => $val)
{   
if($i<=30)
{

?>

<li style="margin:10px 6px 10px 0px; float:left!important; ">                                                   
<a href="<?php echo $this->getUrl('keywords/view/products/key/') ?><?php echo $data; ?>" style="color:#BE0171; text-decoration:none;">  <?php echo $data; ?>            
</a>                    
</li>

<?php

$i++;
}
else
{
break;
}
}

?>

</ul>

<?php endif; ?>             

</div>

XY

-x1-y1-x2-y2 - &gt;所有关键字都显示在此代码中。

但我需要实施上述命令。

0 个答案:

没有答案