1
크기, 색상 및 가격과 같은 관련 주문의 주문 및 제품 속성을 결합하는 테이블은 어느 것입니까?제품 속성 및 주문을 magento에 결합한 테이블
예를 들어, 내 주문서에 셔츠가 들어있는 경우, 나는 질의를 통해 셔츠의 색상과 크기를 알아야합니다.
크기, 색상 및 가격과 같은 관련 주문의 주문 및 제품 속성을 결합하는 테이블은 어느 것입니까?제품 속성 및 주문을 magento에 결합한 테이블
예를 들어, 내 주문서에 셔츠가 들어있는 경우, 나는 질의를 통해 셔츠의 색상과 크기를 알아야합니다.
먼저 주문에서 제품 ID를 가져 와서 해당 제품의 수퍼 속성을 가져와야합니다.
$order_id = 10002; // Your order ID;
$order = Mage::getModel('sales/order')->load($order_id);
$items = $order->getAllVisibleItems();
foreach($items as $item) {
$connection = Mage::getSingleton('core/resource')->getConnection('core_read');
$sql = ("SELECT * FROM (
SELECT
ce.sku,
ea.attribute_id,
ea.attribute_code,
CASE ea.backend_type
WHEN 'varchar' THEN ce_varchar.value
WHEN 'int' THEN ce_int.value
WHEN 'text' THEN ce_text.value
WHEN 'decimal' THEN ce_decimal.value
WHEN 'datetime' THEN ce_datetime.value
ELSE ea.backend_type
END AS value,
ea.is_required AS required
FROM catalog_product_entity AS ce
LEFT JOIN eav_attribute AS ea
ON ce.entity_type_id = ea.entity_type_id
LEFT JOIN catalog_product_entity_varchar AS ce_varchar
ON ce.entity_id = ce_varchar.entity_id
AND ea.attribute_id = ce_varchar.attribute_id
AND ea.backend_type = 'varchar'
LEFT JOIN catalog_product_entity_int AS ce_int
ON ce.entity_id = ce_int.entity_id
AND ea.attribute_id = ce_int.attribute_id
AND ea.backend_type = 'int'
LEFT JOIN catalog_product_entity_text AS ce_text
ON ce.entity_id = ce_text.entity_id
AND ea.attribute_id = ce_text.attribute_id
AND ea.backend_type = 'text'
LEFT JOIN catalog_product_entity_decimal AS ce_decimal
ON ce.entity_id = ce_decimal.entity_id
AND ea.attribute_id = ce_decimal.attribute_id
AND ea.backend_type = 'decimal'
LEFT JOIN catalog_product_entity_datetime AS ce_datetime
ON ce.entity_id = ce_datetime.entity_id
AND ea.attribute_id = ce_datetime.attribute_id
AND ea.backend_type = 'datetime'
WHERE ce.entity_id = ".$item->getProductId()."
) AS tab
WHERE tab.value != ''")
$rows = $connection->fetchAll($sql);
print_r($rows);
}
덕분에,이 SQL은 모두가 주어진 제품의 속성 옵션 제공합니다. 하지만 주문 특정 속성 옵션 만 가져 오려고합니다. 예를 들어, 티셔츠를 주문한 경우 주문한 티셔츠의 크기와 색상을 – Dilani
으로 가져오고 싶습니다. select product_options FROM sales_flat_order_item and magento에서 얻을 수 있습니다. 주문 상품에서 이런 식으로. $ orderItem-> getProductOptions(). 데이터베이스에서이 세부 정보를 직렬화 된 형식으로 저장했습니다. –