I need to get a list of ordered physical items to ship from the database. The list need to consist of name, sku, quantity, price, weight, and dimensions.
How can we fo this without using Magento's own framework components.
The problem is that if a product contains options it appears multiple times in the table by different product types (simple, bundle, configurable, etc.) and different product ids.
$items = array();
$sql = (
"SELECT oi.name, oi.sku, oi.qty_ordered, oi.price, oi.weight
FROM {$db->prefix}sales_flat_order_item oi
WHERE oi.order_id = ". (int)$order_entity_id .";"
);
if ($result = $mysqli->query($sql)) {
while ($row = $result->fetch_assoc()) {
$items[] = [
'name' => $row['name'],
'sku' => $row['sku'],
'quantity' => (float)$row['qty_ordered'],
'unit_price' => (float)$row['price'],
'unit_weight' => (float)$row['weight'],
//'unit_length' => (float)$row['length'], // Not present?
//'unit_width' => (float)$row['width'], // Not present?
//'unit_height' => (float)$row['height'], // Not present?
];
}
$result->close();
}
If I pass a filter AND product_type = 'simple' to get only the simple products, they do not contain price.