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

Maishen technologies

Welcome visitor! You canlogin orcreate an account.

热线:+86-0532-58973093

麦神科技有限公司
Mygod Technologies

官方认证开发工程师

如何在magento产品分类页面调出来细节图呢?

2011年5月18日星期三 Asia/Shanghai下午11:29:09

如何在magento产品分类页面调出来细节图呢

 

在分类页面,如果想在下面加几个细节图,然后当鼠标放在上面,然后上面的图片转换,有点想产品详细页面那种感觉,也是个不错的体验,下面介绍怎么调出来图片

在catalog/product/list/phtml中找到下面这行代码的位置,当然这个文件代码有两段,一段是用于list,一段用于grid,找到grid里面的下面的代码

 <h2 class="product-name"><a href="<?php echo $_product->getProductUrl() ?>" title="<?php echo $_productNameStripped; ?>"><?php echo $_helper->productAttribute($_product, $_product->getName() , 'name'); ?></a></h2>

 

然后把这段代码插入,强势插入,哈!

 

                     <?php //添加的代码?>
                    <?php
                    $product = Mage::getModel('catalog/product')->load($_product->getId());
                    $galleryImages = $product->getMediaGalleryImages();
                     foreach ($galleryImages as $_image): ?>
                        <li>
                        <a href="<?php echo $_image->url; ?>" class=""  id="thumb<?php echo $i ?>" onclick="jSelectImage('<?php echo $i ?>'); return false;">
                            <img src="<?php echo $this->helper('catalog/image')->init($_product, 'thumbnail', $_image->getFile())->resize(56); ?>" alt="<?php echo $this->htmlEscape($_image->getLabel()) ?>" title="<?php echo $this->htmlEscape($_image->getLabel()) ?>" />
                        </a>
                        </li>
                    <?php ++$i; endforeach; ?>
                    <?php //代码结束?>

ok,出来了!

$_image->url为细节图的大图地址,

<?php echo $this->helper('catalog/image')->init($_product, 'thumbnail', $_image->getFile())->resize(56); ?>为细节图的小图地址,resize中的参数56,是细节图小图图片大小的设定。

然后,自己写脚本实现你想要的功能吧!

转载请标注原创链接地址:magentowater:http://www.magentowater.com/blog/magento-catalog-page

0 Comments | Posted in magento扩展 By Terry

magento获取指定目录分类的子分类

2011年5月18日星期三 Asia/Shanghai下午9:17:03

 

 

magento获取指定目录分类的子分类

下面是取得子分类的代码,后面有注释,有兴趣的可以看看。

if ( $category ->hasChildren()) {  //判断是否有子目录

  $ids = $category ->getChildren();   //提取子目录id清单

  $subCategories = Mage::getModel( 'catalog/category' )->getCollection();

  $subCategories ->getSelect()->where( "e.entity_id in ($ids)" );  //提取指定目录ids的上当清单

  $subCategories ->addAttributeToSelect( 'name' );  //指定查找目录名称

  $subCategories ->load();

  foreach ( $subCategories AS $item ) {

  echo " - " ;

  echo '<a href="' . $item ->getUrl() . '">' ;   //获取目录链接

  echo $item ->getName();   //获取目录名

  echo "</a>(" ;

  echo $item ->getProductCount();   //获取目录下的产品数量

  //echo $item->getChildrenCount();  //获取目录下子目录数量

  echo ")" ;

  echo "<br/>" ;

  }

  }

 

 

转载请标注地址:magentowaterhttp://www.magentowater.com/blog/magento-zifenlei


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

给magento的分类加一个字段,一个属性

2011年5月18日星期三 Asia/Shanghai下午9:06:07

给magento的分类加一个属性 大家应该都知道,在magneto的后台,产品属性是可以添加一个的,但是如果给分类加一个属性呢?

因为magento的产品表和分类表都是有很多表组成,其中有eav表,从原理上讲,他们都是可以添加的,只不过magento的后台没有给分类添加这个功能,可能是用处不大吧,有对给magneto添加一个属性感兴趣的朋友,自己翻译吧,呵呵,下面就是方法:

How to add new fields in magento e-commerce?

There is no easy method like adding product attribute for category yet. But we can achieve this by adding from database. You just need to deal with three tables in the database.

First one is: eav_attribute

Insert details as: [change as you need]

01 `attribute_id` = '' ,
02 `entity_type_id` = 9,
03 `attribute_code` = 'logo_size' ,
04 `attribute_model` = NULL,
05 `backend_model` = '' ,
06 `backend_type` = 'text' ,
07 `backend_table` = '' ,
08 `frontend_model` = '' ,
09 `frontend_input` = 'textarea' ,
10 `frontend_label` = 'Embroidery Size Options' ,
11 `frontend_class` = NULL,
12 `source_model` = '' ,
13 `is_required` = 0,
14 `is_user_defined` = 0,
15 `default_value` = '' ,
16 `is_unique` = 0,
17 `note` = ''

Note the inserted attribute_id's value and insert data on another table: eav_entity_attribute

1 `entity_attribute_id` = '' ,
2 `entity_type_id` = 9,
3 `attribute_set_id` = 12,
4 `attribute_group_id` = 7,
5 `attribute_id` = 968, [attribute_id you get from first table insert]
6 `sort_order` = 8

Now the final one: catalog_eav_attribute

01 `attribute_id` = 968, [attribute_id you get from first table insert]
02 `frontend_input_renderer` = NULL,
03 `is_global` = 0
04 `is_visible` = 1,
05 `is_searchable` = 0,
06 `is_filterable` = 0,
07 `is_comparable` = 0,
08 `is_visible_on_front` = 0,
09 `is_html_allowed_on_front` = 0,
10 `is_used_for_price_rules` = 1,
11 `is_filterable_in_search` = 0,
12 `used_in_product_listing` = 0,
13 `used_for_sort_by` = 0,
14 `is_configurable` = 1,
15 `apply_to` = '' ,
16 `is_visible_in_advanced_search` = 0,
17 `position` = 1,
18 `is_wysiwyg_enabled` = 0

Thats all you need to do to add new field in the manage category for magento e-commerce based websites.

Same as other values you can get the value of this field in the frontend template as below:

1 $this ->getCurrentCategory()->getLogoSize();

You can modify rest as your need.

 

转载请标注链接:magentowaterhttp://www.magentowater.com/blog/magento-catalog-ziduan

0 Comments | Posted in magento扩展 By Terry

如何去掉多网店的URL中___store 和___from_store

2011年5月18日星期三 Asia/Shanghai下午8:39:32

如何去掉多网店的URL中___store 和___from_store

在多网店的模式中,会出现?___store=cn&___from_store=jp,等这些字符,这种URL对搜索引擎是不友好的,而且容易造成重复页面,所以要去掉,去掉就要去找代码,呵呵

其实很简单

找到文件app/code/core/mage/core/model/store.php

大约897行

 . (isset($storeParsedUrl['port']) ? ':' . $storeParsedUrl['port'] : '')

            . $storeParsedUrl['path'] . $requestString

            . ($storeParsedQuery ? '?'.http_build_query($storeParsedQuery, '', '&amp;') : '');

. ($storeParsedQuery ? '?'.http_build_query($storeParsedQuery, '', '&amp;') : '');

去掉

就是改成

 . (isset($storeParsedUrl['port']) ? ':' . $storeParsedUrl['port'] : '')

            . $storeParsedUrl['path'] . $requestString;

OK,刷新缓存,没了!!!!嬲性!!!

顺着摸出来的,哈
!!!!!!!!

转载请标注地址:magentowater:http://www.magentowater.com/blog/url-store

 

 


0 Comments | Posted in magento二次开发 By Terry

magento URL静态化,固定化,url经常变动的问题的解决

2011年5月18日星期三 Asia/Shanghai下午8:33:10

在magento中,URL,使用magento的方法的magento经常变动,做seo需要稳定的重写后URL譬如:

http://www.magentowater.com/silverjewellerystores.com/jp/catalog/product/view/id/115/category/882/

我们希望是重写后的URL

http://www.magentowater.com/silverjewellerystores.com/lovely-heart-style-925-silver-woman-bracelet-b001-283

但是,magneto的URL,在某些情况下,经常的变动,这会给seo造成困难,被谷歌认为重复页面,进而降低对这个网站的权重,我们可以通过数据库取值的方式,对URL通过字符串拼接的方式生成,下面是代码:

可以通过下面的方法:

$resource = Mage::getSingleton('core/resource');  
$read = $resource->getConnection('core_read'); 

$productTable = (string)Mage::getConfig()->getTablePrefix().'catalog_product_entity_varchar';

$store_idd    = Mage::app()->getStore()->getId();

 foreach($ids as $id){
             $product_s  = Mage::getModel('catalog/product')->load($id);  
                 $select = $read->select()  
                       ->from(array('cp'=>$productTable))  
                       ->where('cp.entity_id=?', $id)
                       ->where('cp.attribute_id=?',86)
                       ->where('store_id=?',$store_idd)
                       ->limit(3) ;
                 // echo  $select;   
                 $rows = $read->fetchAll($select);
                 foreach($rows as $row){
                         $product_url = Mage::getBaseUrl('web').$row['value']; 
                   }
                // $product_url = Mage::getBaseUrl('web').$rows[0]['value'];
             $product_s->setProductUrls($product_url);
              $_producttt[]=  $product_s; 
         }   
         
        $tt = count($_producttt);
        if($tt<10){
            $ss = $tt;
        }else{
            $ss = 10;
        }
        
            $rand=array_rand($_producttt,$ss);
foreach ($rand as $v) {
  $_products[]=$_producttt[$v];
}

原理大致为从catalog_product_entity_varchar表中取出URL_key,不同的magento安装后,好像URL_KEY对应的attribute_id貌似不一样,在我的系统里面是86,进而把ID对应的urlkey遍历出来,通过字符串拼接$product_url = Mage::getBaseUrl('web').$row['value'];得到重写后的URL,当然也和重写规则设置对应!!!!

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

订阅我们的最新消息。

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

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

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