“我的订单"表格仅包含当前商店视图中的订单 [英] "My order" table just with orders from current store view

查看:106
本文介绍了“我的订单"表格仅包含当前商店视图中的订单的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个maganto安装(1.4.0.1),其中包含多个网站和多个商店/商店视图.另外,我在所有商店视图中都有不同的产品.当我进入我的帐户"->我的订单"时,将显示所有商店的订单.我可以在某个位置进行配置或更改代码中的某些内容以仅从当前打开的商店视图中获得具有顺序的列表吗?

换句话说,如果我在订单mywebsite.com/store2/sales/order/history/中进入我的网站mywebsite.com/store2上的商店2,它将显示所有网站的订单历史记录,但是我需要我仅显示"store2"形式的订单.

我希望有人对此问题或类似问题有答案,如果能帮助我,我将不胜感激.

乔丹

解决方案

    /*GetCurrent Website Name*/
    $currentWebsiteName = Mage::app()->getStore()->getWebsite()->getName();        
    $currentWebsiteName_LIKE_PHRASE = '%'.$currentWebsiteName.'%';

    /*Filter the Order Collection by Current Website Name*/
    $orders = Mage::getResourceModel('sales/order_collection')
        ->addFieldToSelect('*')
        ->addFieldToFilter('customer_id', Mage::getSingleton('customer/session')->getCustomer()->getId())
        ->addFieldToFilter('state', array('in' => Mage::getSingleton('sales/order_config')->getVisibleOnFrontStates()))
        ->addAttributeToFilter('store_name', array('like' => $currentWebsiteName_LIKE_PHRASE))
        ->setOrder('created_at', 'desc');

   /*Note the Below Line*/
   ->addAttributeToFilter('store_name', array('like' => $currentWebsiteName_LIKE_PHRASE))

Am按当前网站名称过滤.刚获得 sales_flat_order 表可以查看此列"商店名称",您可以在其中找到它还包含网站名称.

不幸的是,我无法在此主订单表或其相关表中找到网站ID ,无法对订单集合进行 JOIN声明.我认为您可能有一些带有** _ website 后缀**的订单表,如果是这种情况,您可以轻松地将其加入我们现有的收藏集

I have one maganto installation (1.4.0.1) with several web site and several store/store view. Also I have different product in all store views. When I go My Account-> My orders in the table is show the orders from all stores. Can I config somewhere or change something in code to have list with order just from current open store view?

With other word, if I go on store 2 on my web site mywebsite.com/store2 in my orders mywebsite.com/store2/sales/order/history/ it show orders history from all web sites, but I need me to show orders just form "store2".

I hope someone have answer for this or similar issue and I will be grateful if help me.

Jordan

解决方案

    /*GetCurrent Website Name*/
    $currentWebsiteName = Mage::app()->getStore()->getWebsite()->getName();        
    $currentWebsiteName_LIKE_PHRASE = '%'.$currentWebsiteName.'%';

    /*Filter the Order Collection by Current Website Name*/
    $orders = Mage::getResourceModel('sales/order_collection')
        ->addFieldToSelect('*')
        ->addFieldToFilter('customer_id', Mage::getSingleton('customer/session')->getCustomer()->getId())
        ->addFieldToFilter('state', array('in' => Mage::getSingleton('sales/order_config')->getVisibleOnFrontStates()))
        ->addAttributeToFilter('store_name', array('like' => $currentWebsiteName_LIKE_PHRASE))
        ->setOrder('created_at', 'desc');

   /*Note the Below Line*/
   ->addAttributeToFilter('store_name', array('like' => $currentWebsiteName_LIKE_PHRASE))

Am filtering by current website name. Just got the sales_flat_order table can view this column 'store_name' where you can find it also contains the website Name.

Unfortunately i can't find website id in this main order table or in its related table to make a JOIN statement to the order collection. I think you might have some order table with **_website suffix**, if thats the case you can easily join that to our existing collection

这篇关于“我的订单"表格仅包含当前商店视图中的订单的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
相关文章
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆