1. SQL / Говнокод #8215

    −115

    1. 01
    2. 02
    3. 03
    4. 04
    5. 05
    6. 06
    7. 07
    8. 08
    9. 09
    10. 10
    11. 11
    12. 12
    13. 13
    14. 14
    15. 15
    16. 16
    17. 17
    18. 18
    SELECT product.entity_id as pid, 
           vTitle.value as title, vLength.value as length, vWidth.value as width, vHeight.value as height, vWeight.value as weight, vCapacity.value as capacity, vImg.value as img,
           tShort.value as short, tText.value as text,
           dPrice.value as price,
           cParent.category_id as parent
    FROM catalog_product_entity as product
    LEFT JOIN catalog_product_entity_varchar as vTitle ON vTitle.entity_id=product.entity_id AND vTitle.attribute_id=60
    LEFT JOIN catalog_product_entity_varchar as vLength ON vLength.entity_id=product.entity_id AND vLength.attribute_id=122
    LEFT JOIN catalog_product_entity_varchar as vWidth ON vWidth.entity_id=product.entity_id AND vWidth.attribute_id=123
    LEFT JOIN catalog_product_entity_varchar as vHeight ON vHeight.entity_id=product.entity_id AND vHeight.attribute_id=124
    LEFT JOIN catalog_product_entity_varchar as vWeight ON vWeight.entity_id=product.entity_id AND vWeight.attribute_id=69
    LEFT JOIN catalog_product_entity_varchar as vCapacity ON vCapacity.entity_id=product.entity_id AND vCapacity.attribute_id=125
    LEFT JOIN catalog_product_entity_varchar as vImg ON vImg.entity_id=product.entity_id AND vImg.attribute_id=74
    LEFT JOIN catalog_product_entity_text as tShort ON tShort.entity_id=product.entity_id AND tShort.attribute_id=62
    LEFT JOIN catalog_product_entity_text as tText ON tText.entity_id=product.entity_id AND tText.attribute_id=61
    LEFT JOIN catalog_product_entity_decimal as dPrice ON dPrice.entity_id=product.entity_id AND dPrice.attribute_id=64
    LEFT JOIN (SELECT c.category_id, c.product_id FROM catalog_category_product as c ORDER BY c.category_id DESC) as cParent ON cParent.product_id=product.entity_id
    GROUP BY cParent.product_id ORDER BY cParent.product_id

    Мой говнокод-неговнокод по экспорту товара из Magento в нашу CMS

    Запостил: Android991, 17 Октября 2011

    Комментарии (5) RSS

    Добавить комментарий