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.
if we login as Designer ,
1) Product name & Product Id are not displaying. but i want to display
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';
Mage::app();
$stmts = $user_home->runQuery("SELECT * FROM tbl_users WHERE userID=:uid");
$stmts->execute(array(
":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'
));
}
else
{
$order = Mage::getModel('sales/order')->getCollection()->addAttributeToFilter('designer_id', array(
'like' => '%' . $_SESSION['userSession'] . '%'
))
->addAttributeToSelect('created_at')
->addAttributeToSelect('increment_id') // order id
->addAttributeToSelect('status')
->addAttributeToSelect('grand_total')
->addAttributeToSelect('customer_email')
->addAttributeToSelect('state');
}
$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);
}