magento一店多语言切换,URL处理发布时间:2012-05-09

escape(
    trim(Mage::app()->getRequest()->getRequestString(), '/')
);
$sql = $resource->getConnection('default_read')->select()->from($resource->getTableName('core/url_rewrite'))
        ->where('request_path=?',$requestPath)
        ->where('store_id=?',Mage::app()->getStore()->getId());
$select2 = (array) $resource->getConnection('default_read')
    ->fetchAll($sql);
if($select2) :
$sql2 = 'SELECT * FROM core_url_rewrite WHERE id_path="'.$select2[0]['id_path'].'" AND target_path="'.$select2[0]['target_path'].'"';
$select = $resource->getConnection('default_read')->fetchAll($sql2);
?>
getStores())>1): ?>
举例说明我遇到的问题: 站内有a,b,c三种语言,假设现在是在A站下的test.html这个URL下,切换语言到b,url就会变成test.html__from_store=a,这时候的页面是正常的,原因不说大家也明白,然后url和后面的参数能帮助b语言找到相对应的产品或者分类,如果再从b切换到c的时候,问题就出现了,直接404了,url是test.html__from_store=b。。后面的参数传的不对。很蛋疼。。。我试了很多方法,我有想过把core_url_rewrite表里从a店里来的request_path,在b店里加一个target_path,这样也能去掉__from_store

复制Magento分类发布时间:2012-04-01

global->resources->default_setup->connection->host;
$username = $xml->global->resources->default_setup->connection->username;
$password = $xml->global->resources->default_setup->connection->password;
$dbname = $xml->global->resources->default_setup->connection->dbname; 
$res = mysql_pconnect($host, $username, $password);   
mysql_select_db($dbname);
 
 
 
 
$catsDone = 0;
duplicate_entity($catId);
echo $catsDone . ' Categories duplicated.';
 
function duplicate_entity($id, $parent_id = null){
	global $catsDone;
 
 
	// Grab category to copy
	$sql = "SELECT * FROM catalog_category_entity WHERE entity_id = " . $id;
	$query_entity = mysql_query($sql);
 
	$entity = mysql_fetch_object($query_entity);
 
 
	if(!$parent_id)$parent_id = $entity->parent_id;
 
 
 
 
	mysql_query("INSERT INTO catalog_category_entity (entity_type_id, attribute_set_id, parent_id, created_at, updated_at, path, position, level, children_count)
						VALUES ({$entity->entity_type_id}, {$entity->attribute_set_id}, {$parent_id}, NOW(), NOW(), '', {$entity->position}, {$entity->level}, {$entity->children_count})");
	$newEntityId = mysql_insert_id();
 
	$query = mysql_query("SELECT path FROM catalog_category_entity WHERE entity_id = " . $parent_id);
	$parent = mysql_fetch_object($query);
	$path = $parent->path . '/' . $newEntityId;
 
	mysql_query("UPDATE catalog_category_entity SET path='". $path."' WHERE entity_id=". $newEntityId);
 
 
	foreach(array('datetime', 'decimal', 'int', 'text', 'varchar') as $dataType){
		$sql = "SELECT * FROM catalog_category_entity_".$dataType."
				WHERE entity_id=" . $entity->entity_id;
				//die($sql);
		$query = mysql_query($sql);
		while ($value = mysql_fetch_object($query)){
			mysql_query("INSERT INTO catalog_category_entity_".$dataType." (entity_type_id, attribute_id, store_id, entity_id, value)
							VALUES ({$value->entity_type_id}, {$value->attribute_id}, {$value->store_id}, {$newEntityId}, '{$value->value}')");
		}
	}
 
 
	$sql = "SELECT entity_id FROM catalog_category_entity WHERE parent_id = " . $id;
	$query = mysql_query($sql);
 
	while ($entity = mysql_fetch_object($query)){
		duplicate_entity($entity->entity_id, $newEntityId);
	}
	$catsDone++;
}
 
 
 
 
?>
代码没有测试过,这里面的一些方法以后用得着。

推荐:Magento多运费表格扩展(Multiple Tab发布时间:2012-03-15

http://www.magentocommerce.com/magento-connect/webshopapps-matrixrate-1-multiple-table-rates-extension-certified-bug-free.html     表格的格式直接从后台导出,看一下就知道什么意思了。有不明白的可以留言!

选择跟程序员约会的10个理由发布时间:2012-03-07

前两天我正在头脑风暴一些极客(geek)想法的时候,我的老婆突然跟我讲,你应该写一篇文章,讲讲和程序员约会的10个理由。我愣了一下,“这个应该你告诉我才对啊!”  我和老婆结婚已经十多年了,我也一直在想为什么她会选择我?难道我的极客行为没有把她逼疯掉吗?在一顿长谈之后,我们总结出以下十点。 1. 我们很忠诚 程序员与生俱来忠诚的品质。如果一个人能忠诚于硬件,操作系统等枯燥的玩意儿的话,你可以想象当他遇到另一半的时候,会是怎样的忠诚。 2. 我们很细心 看看程序员、极客们是对待他们心爱的收藏,例如各种小部件,CPU等等,你就可以明白当他爱上你以后,他会如何细心的对

Magento识别IPHONE,IPAD,ANDROID设备发布时间:2012-02-27

又学了一个。不过我手里没有设备测试。直接上图片了。一看就明白了。   关于Magento在移动设备端的支付有哪位朋友了解的多一点的,欢迎交流

苹果 Mac OS X 系统屏幕截图快捷键发布时间:2012-02-06

苹果Mac OS X 系统下屏幕截图快捷键: 1) Command-Shift-3:将整个屏幕拍下并保存到桌面; 2) Command-Shift-Control-3:将整个屏幕拍下并保存到剪贴板(Clipboard),你可以Command+V直接粘贴到如Photoshop等软件中编辑; 3) Command-Shift-4:将屏幕的一部分拍下并保存到桌面。当按下着几个键后,光标会变为一个十字,你可以拖拉来选取拍摄区域; 4) Command-Shift-Control-4:将屏幕的一部分拍下并保存到剪贴板; 5) Command-Shift-Capslock-4:将当前的窗口拍

史上最暴力的Magento插件开源列表,板砖啊,口水啊,律师发布时间:2011-11-21

aw_helpdeskultimate-2.6.6.community_edition.zip Help Desk Ultimate  The Help Desk Ultimate extension is a turnkey solution for Magento-based websites. It’s a perfect customer care and support Magento module with an efficient case tracking and resolution system indispensable for a succes

Magento social sharing button 发布时间:2011-09-19

tweet button facebook like send google+1 button   下载地址