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

if we login as admin , than we can see all order informations.

enter image description here

if we login as Designer ,

1) Product name & Product Id are not displaying. but i want to display

enter image description here

Here Order id, Order Date are fetching from "sales_flat_order" table.

Product Id, Product name are fetching from "sales_flat_order_item" table

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

function getDesignerCollection()
    $user_home = new USER();
    require_once '../../app/Mage.php';

    $stmts = $user_home->runQuery("SELECT * FROM tbl_users WHERE userID=:uid");
        ":uid" => $_SESSION['userSession']
    $rows = $stmts->fetch(PDO::FETCH_ASSOC);

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

    $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");
                    ":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() ,
                    $productdetail->getName() ,


    echo json_encode($responce);

1 Answer 1


I think you are not getting any thing on this line:

$productdetail = Mage::getModel('catalog/product')->load($orderitemsarray[$k]);

Please make sure that you are getting the data in $orderitemsarray, as I think you have to get the product object in that. But it is not getting that object anyhow so you are not getting the product details, as a result product id, name and designer details are not displayed correctly.

  • Before product_id , product name, designer id all were displaying, I don't want to display Designer_id, so i followed this link answer , but now i want to display product id & name. if i use this code : ->addAttributeToSelect('dproduct_id'), than product id, name will display. but along with that it will display designer id also , i don't want that. Commented Dec 1, 2016 at 6:14
  • can you please update the answer with code to get results of product id & name Commented Dec 1, 2016 at 6:14
  • If you are getting the product id, name & designer id in ->addAttributeToSelect('dproduct_id') as array, than you can unset the designer id from it. Like From your code you are getting that details in $orderitems = $orderData['dproduct_id']; So if the result you are getting as an array than you can unset that from the variable $orderitems I am not writing the code as I dont have the exact idea in which form you are getting the details of product id,name and designer id. Commented Dec 1, 2016 at 6:43
  • can you please tell what code i need to use to unset the designer id as array..... Commented Dec 1, 2016 at 6:44
  • you can do it by using unset($orderitems['designer_id']). You can use the key for designer id you are getting in that array in place of designer_id. Commented Dec 1, 2016 at 6:48

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.