0

we are displaying all the order related information in custom page : www.1234.com/php/site6/orders.php

if we login than we can see all orders. Here Order id, Prodcut Ids..etc are fetching from magento database.

enter image description here

but only Designer column is fething from custom database [ table : tbl_users , column: name ]

enter image description here

There are 2 types of dashboard - admin & designer, if designer login than we want to hide column Designer

php

function getDesignerCollection()

$stmt = $user_home->runQuery("SELECT * FROM tbl_users WHERE userID=:uid");
    $stmt->execute(array(
        ":uid" => $designerId
    ));
    $row = $stmt->fetch(PDO::FETCH_ASSOC);
    return $row['name'];
    }

    {
    $accountType = $rows['type'];
    if ($accountType == "admin")
        {
        $order = Mage::getModel('sales/order')->getCollection()->addAttributeToFilter('designer_id', array(
            'nin' => '0'
        ));     
        }
      else
        {
        $order = Mage::getModel('sales/order')->getCollection()->addAttributeToFilter('designer_id', array(
            'like' => '%' . $_SESSION['userSession'] . '%'
        ));     
        }

    $i = 0;
    foreach($order as $orderData)
        {
        $orderitems = $orderData['dproduct_id'];
        $orderitemsarray = explode(",", $orderitems);
        $k = 0;
        $oDate = new DateTime($orderData['created_at']);
        $sDate = $oDate->format("Y-m-d");
        while ($k < count($orderitemsarray))
            {
            if ($orderitemsarray[$k] != '0')
                {
                $stmtorders = $user_home->runQuery("SELECT * FROM order_details WHERE designerorder_id=:designerorder_id");
                $stmtorders->execute(array(
                    ":designerorder_id" => $orderData['entity_id']
                ));
                $roworders = $stmtorders->fetch(PDO::FETCH_ASSOC);
                $productdetail = Mage::getModel('catalog/product')->load($orderitemsarray[$k]);
                $designerName = getDesignerName($productdetail->getDesignerID()) . " -(" . $productdetail->getDesignerID() . ")";
                $responce[] = array(
                    $orderData->getIncrementId() ,
                    $orderData->getIncrementId() ,
                    $orderitemsarray[$k],
                    $productdetail->getName() ,
                    $designerName,
                    $orderData['status'],
                    $orderData['grand_total'],
                    $orderData['customer_email'],
                    $commission,
                    $dorderStatus,
                    $sDate
                );
                }

            $k++;
            $i++;
            }
        }

    echo json_encode($responce);
    }

script

var dsOption= {
    fields :[   
        {name : 'entity_id'  }, 
        {name : 'entity_id'  },
        {name : 'product_id'  },
        {name : 'product_name'},
        {name : 'designer_id'  },       
        {name : 'status'  },        
        {name : 'grand_total'  },
        {name : 'customer_email'  },
        {name : 'commission'  },    
        {name : 'paid_status'  },       
        {name : 'created_at'},                  
    ],
    recordType : 'array',
    data : __TEST_DATA__
}   

var colsOption = [  
    {id: 'entity_id' , header: "Order Id" , width :"15",renderer : my_renderId},   
    {id: 'created_at' , header: "Order Date" , width :"120"},
    {id: 'entity_id' , header: "Order Id" , width :"75"},
    {id: 'product_id' , header: "Product Id" , width :"70"},
    {id: 'product_name' , header: "Product Name" , width :"200"},
    {id: 'designer_id' , header: "Designer" , width :"110"},
    {id: 'status' , header: "Order Status" , width :"100"},  
    {id: 'grand_total' , header: " Order Amount" , width :"120"},
    {id: 'customer_email' , header: "User Email" , width :"150"},     
    {id: 'paid_status' , header: "Paid status" , width :"80"},
    {id: 'commission' , header: "commission" , width :"80"}

];

If i remove below line from above script, than "Designer" column will hide in both admin & Designer dashboard.

{id: 'designer_id' , header: "Designer" , width :"110"},
2
  • This is a PHP only question. Even though it's linked to a Magento database it does not involve Magento code thus I suggest you ask it on stackoverflow.com Commented Dec 2, 2016 at 14:17
  • @RaphaelatDigitalPianism Thanks for your comment, when i asked same questions in stackoverflow, they suggested me to ask here as because the question involves code like $order = Mage::getModel('sales/order')->getCollection()->addAttributeToFilter('designer_id', array( 'like' => '%' . $_SESSION['userSession'] . '%' )); , so i asked here, i will take your suggestion & try to ask in stackoverflow if the question is purely related to php.... Commented Dec 5, 2016 at 5:10

3 Answers 3

2
+50

Change below code:

$order = Mage::getModel('sales/order')->getCollection()->addAttributeToFilter('designer_id', array(
            'like' => '%' . $_SESSION['userSession'] . '%'
        )); 

To:

$order = Mage::getModel('sales/order')->getCollection()->addAttributeToFilter('designer_id', array(
            'like' => '%' . $_SESSION['userSession'] . '%'
        ))
->addAttributeToSelect('created_at') 
->addAttributeToSelect('customer_id') 
->addAttributeToSelect('increment_id') 
->addAttributeToSelect('updated_at') 
->addAttributeToSelect('status') 
->addAttributeToSelect('entity_id')
->addAttributeToSelect('state');

Add your field which you need to show for designer collection

6
  • yes designer names are hiding, but I want to hide complete column prnt.sc/ddij3b , also product_id & product_names are also hiding, i used this code to display those, but still its not displaying , code : ->addAttributeToSelect('product_id') & ->addAttributeToSelect('product_name') Commented Nov 30, 2016 at 7:41
  • please check product name and product id in your collection or not Commented Nov 30, 2016 at 7:45
  • when i used this code : ->addAttributeToSelect('dproduct_id') product id , product name will display, but designer names will also display.... Commented Nov 30, 2016 at 10:22
  • all other columns information are fetching from sales_flat_order table, but there is no product_id & product_name columns in sales_flat_order table , is that is the reason ? Commented Nov 30, 2016 at 11:25
  • Yes may be that would be reason Commented Nov 30, 2016 at 11:26
3

You can achieve this from the CSS also.

for this you have to add a css class "designer" in all column of designer including header of designer tab.

In Head section call a block file where you can check the user type and on the basis of that you can add a css of "designer" class with display:none.

8
  • can you please give me an example for how i can add css class for atleast one column . is there any way we can add css for below javscript line : var colsOption = [ {id: 'entity_id' , header: "Order Id" , width :"15",renderer : my_renderId}, ]; Commented Dec 5, 2016 at 5:34
  • @BabyinMagento you can add css for id 'designer_id' in your case. Commented Dec 5, 2016 at 9:49
  • i tried this : <style> #designer_id { disply : none; } </style> , can you please tell what i need to do for In Head section call a block file where you can check the user type and on the basis of that you can add a css of "designer" class with display:none. Commented Dec 5, 2016 at 10:04
  • can you please tell what else i need to do after line : <style> #designer_id { disply : none; } </style> Commented Dec 5, 2016 at 10:42
  • @BabyinMagento You can add this css inside if ($accountType != "admin") code in top of the page Commented Dec 5, 2016 at 10:47
0
var colsOption = [
    {id: 'entity_id' , header: "Order Id" , width :"15",renderer : my_renderId},
    {id: 'created_at' , header: "Order Date" , width :"120"},
    {id: 'entity_id' , header: "Order Id" , width :"75"},
    {id: 'product_id' , header: "Product Id" , width :"70"},
    {id: 'product_name' , header: "Product Name" , width :"200"},
<?php if ($is_admin) echo "{id: 'designer_id' , header: 'Designer' , width :'110'},"; ?>
    {id: 'status' , header: "Order Status" , width :"100"},
    {id: 'grand_total' , header: " Order Amount" , width :"120"},
    {id: 'customer_email' , header: "User Email" , width :"150"},
    {id: 'dpaid_status' , header: "Paid status" , width :"80"},
    {id: 'commission' , header: "commission" , width :"80"}

];

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.