Get all product from MAGENTO (sql query)












0















I want to get all products that are stored in the database. I want those products that have these attributes:



SKU, code_brand, code_business_unit, code_line, code_group, code_business


The problem is that after executing my query it does not show any errors but it is not displaying the products (empty rows).



This is my query:



SELECT 
main.entity_id,
main.sku,
code_brand.value AS code_brand,
code_business_unit.value AS code_business_unit,
code_line.value AS code_line,
code_group.value AS code_group,
code_business.value AS code_business

FROM catalog_product_entity AS main

LEFT JOIN catalog_product_entity_int AS code_brand
ON main.entity_id = code_brand.entity_id

LEFT JOIN catalog_product_entity_varchar AS code_business_unit
ON main.entity_id = code_business_unit.entity_id

LEFT JOIN catalog_product_entity_varchar AS code_line
ON main.entity_id = code_line.entity_id

LEFT JOIN catalog_product_entity_int AS code_group
ON main.entity_id = code_group.entity_id

LEFT JOIN catalog_product_entity_int AS code_business
ON main.entity_id = code_business.entity_id


WHERE code_brand.attribute_id = (
SELECT attribute_id
FROM eav_attribute
WHERE attribute_code LIKE "code_brand"
AND 'entity_type_id' = (
SELECT entity_type_id
FROM eav_entity_type
WHERE entity_type_code = 'catalog_product'
)
)

AND code_business_unit.attribute_id = (
SELECT attribute_id
FROM eav_attribute
WHERE attribute_code LIKE "code_business_unit"
AND 'entity_type_id' = (
SELECT entity_type_id
FROM eav_entity_type
WHERE entity_type_code = 'catalog_product'
)
)

AND code_line.attribute_id = (
SELECT attribute_id
FROM eav_attribute
WHERE attribute_code LIKE "code_line"
AND 'entity_type_id' = (
SELECT entity_type_id
FROM eav_entity_type
WHERE entity_type_code = 'catalog_product'
)
)


AND code_group.attribute_id = (
SELECT attribute_id
FROM eav_attribute
WHERE attribute_code LIKE "code_group"
AND 'entity_type_id' = (
SELECT entity_type_id
FROM eav_entity_type
WHERE entity_type_code = 'catalog_product'
)
)


AND code_business.attribute_id = (
SELECT attribute_id
FROM eav_attribute
WHERE attribute_code LIKE "code_business"
AND 'entity_type_id' = (
SELECT entity_type_id
FROM eav_entity_type
WHERE entity_type_code = 'catalog_product'
)
)


What's wrong with my query?



This is the Database diagram:



Image









share







New contributor




programming_amazing is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.

























    0















    I want to get all products that are stored in the database. I want those products that have these attributes:



    SKU, code_brand, code_business_unit, code_line, code_group, code_business


    The problem is that after executing my query it does not show any errors but it is not displaying the products (empty rows).



    This is my query:



    SELECT 
    main.entity_id,
    main.sku,
    code_brand.value AS code_brand,
    code_business_unit.value AS code_business_unit,
    code_line.value AS code_line,
    code_group.value AS code_group,
    code_business.value AS code_business

    FROM catalog_product_entity AS main

    LEFT JOIN catalog_product_entity_int AS code_brand
    ON main.entity_id = code_brand.entity_id

    LEFT JOIN catalog_product_entity_varchar AS code_business_unit
    ON main.entity_id = code_business_unit.entity_id

    LEFT JOIN catalog_product_entity_varchar AS code_line
    ON main.entity_id = code_line.entity_id

    LEFT JOIN catalog_product_entity_int AS code_group
    ON main.entity_id = code_group.entity_id

    LEFT JOIN catalog_product_entity_int AS code_business
    ON main.entity_id = code_business.entity_id


    WHERE code_brand.attribute_id = (
    SELECT attribute_id
    FROM eav_attribute
    WHERE attribute_code LIKE "code_brand"
    AND 'entity_type_id' = (
    SELECT entity_type_id
    FROM eav_entity_type
    WHERE entity_type_code = 'catalog_product'
    )
    )

    AND code_business_unit.attribute_id = (
    SELECT attribute_id
    FROM eav_attribute
    WHERE attribute_code LIKE "code_business_unit"
    AND 'entity_type_id' = (
    SELECT entity_type_id
    FROM eav_entity_type
    WHERE entity_type_code = 'catalog_product'
    )
    )

    AND code_line.attribute_id = (
    SELECT attribute_id
    FROM eav_attribute
    WHERE attribute_code LIKE "code_line"
    AND 'entity_type_id' = (
    SELECT entity_type_id
    FROM eav_entity_type
    WHERE entity_type_code = 'catalog_product'
    )
    )


    AND code_group.attribute_id = (
    SELECT attribute_id
    FROM eav_attribute
    WHERE attribute_code LIKE "code_group"
    AND 'entity_type_id' = (
    SELECT entity_type_id
    FROM eav_entity_type
    WHERE entity_type_code = 'catalog_product'
    )
    )


    AND code_business.attribute_id = (
    SELECT attribute_id
    FROM eav_attribute
    WHERE attribute_code LIKE "code_business"
    AND 'entity_type_id' = (
    SELECT entity_type_id
    FROM eav_entity_type
    WHERE entity_type_code = 'catalog_product'
    )
    )


    What's wrong with my query?



    This is the Database diagram:



    Image









    share







    New contributor




    programming_amazing is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
    Check out our Code of Conduct.























      0












      0








      0








      I want to get all products that are stored in the database. I want those products that have these attributes:



      SKU, code_brand, code_business_unit, code_line, code_group, code_business


      The problem is that after executing my query it does not show any errors but it is not displaying the products (empty rows).



      This is my query:



      SELECT 
      main.entity_id,
      main.sku,
      code_brand.value AS code_brand,
      code_business_unit.value AS code_business_unit,
      code_line.value AS code_line,
      code_group.value AS code_group,
      code_business.value AS code_business

      FROM catalog_product_entity AS main

      LEFT JOIN catalog_product_entity_int AS code_brand
      ON main.entity_id = code_brand.entity_id

      LEFT JOIN catalog_product_entity_varchar AS code_business_unit
      ON main.entity_id = code_business_unit.entity_id

      LEFT JOIN catalog_product_entity_varchar AS code_line
      ON main.entity_id = code_line.entity_id

      LEFT JOIN catalog_product_entity_int AS code_group
      ON main.entity_id = code_group.entity_id

      LEFT JOIN catalog_product_entity_int AS code_business
      ON main.entity_id = code_business.entity_id


      WHERE code_brand.attribute_id = (
      SELECT attribute_id
      FROM eav_attribute
      WHERE attribute_code LIKE "code_brand"
      AND 'entity_type_id' = (
      SELECT entity_type_id
      FROM eav_entity_type
      WHERE entity_type_code = 'catalog_product'
      )
      )

      AND code_business_unit.attribute_id = (
      SELECT attribute_id
      FROM eav_attribute
      WHERE attribute_code LIKE "code_business_unit"
      AND 'entity_type_id' = (
      SELECT entity_type_id
      FROM eav_entity_type
      WHERE entity_type_code = 'catalog_product'
      )
      )

      AND code_line.attribute_id = (
      SELECT attribute_id
      FROM eav_attribute
      WHERE attribute_code LIKE "code_line"
      AND 'entity_type_id' = (
      SELECT entity_type_id
      FROM eav_entity_type
      WHERE entity_type_code = 'catalog_product'
      )
      )


      AND code_group.attribute_id = (
      SELECT attribute_id
      FROM eav_attribute
      WHERE attribute_code LIKE "code_group"
      AND 'entity_type_id' = (
      SELECT entity_type_id
      FROM eav_entity_type
      WHERE entity_type_code = 'catalog_product'
      )
      )


      AND code_business.attribute_id = (
      SELECT attribute_id
      FROM eav_attribute
      WHERE attribute_code LIKE "code_business"
      AND 'entity_type_id' = (
      SELECT entity_type_id
      FROM eav_entity_type
      WHERE entity_type_code = 'catalog_product'
      )
      )


      What's wrong with my query?



      This is the Database diagram:



      Image









      share







      New contributor




      programming_amazing is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
      Check out our Code of Conduct.












      I want to get all products that are stored in the database. I want those products that have these attributes:



      SKU, code_brand, code_business_unit, code_line, code_group, code_business


      The problem is that after executing my query it does not show any errors but it is not displaying the products (empty rows).



      This is my query:



      SELECT 
      main.entity_id,
      main.sku,
      code_brand.value AS code_brand,
      code_business_unit.value AS code_business_unit,
      code_line.value AS code_line,
      code_group.value AS code_group,
      code_business.value AS code_business

      FROM catalog_product_entity AS main

      LEFT JOIN catalog_product_entity_int AS code_brand
      ON main.entity_id = code_brand.entity_id

      LEFT JOIN catalog_product_entity_varchar AS code_business_unit
      ON main.entity_id = code_business_unit.entity_id

      LEFT JOIN catalog_product_entity_varchar AS code_line
      ON main.entity_id = code_line.entity_id

      LEFT JOIN catalog_product_entity_int AS code_group
      ON main.entity_id = code_group.entity_id

      LEFT JOIN catalog_product_entity_int AS code_business
      ON main.entity_id = code_business.entity_id


      WHERE code_brand.attribute_id = (
      SELECT attribute_id
      FROM eav_attribute
      WHERE attribute_code LIKE "code_brand"
      AND 'entity_type_id' = (
      SELECT entity_type_id
      FROM eav_entity_type
      WHERE entity_type_code = 'catalog_product'
      )
      )

      AND code_business_unit.attribute_id = (
      SELECT attribute_id
      FROM eav_attribute
      WHERE attribute_code LIKE "code_business_unit"
      AND 'entity_type_id' = (
      SELECT entity_type_id
      FROM eav_entity_type
      WHERE entity_type_code = 'catalog_product'
      )
      )

      AND code_line.attribute_id = (
      SELECT attribute_id
      FROM eav_attribute
      WHERE attribute_code LIKE "code_line"
      AND 'entity_type_id' = (
      SELECT entity_type_id
      FROM eav_entity_type
      WHERE entity_type_code = 'catalog_product'
      )
      )


      AND code_group.attribute_id = (
      SELECT attribute_id
      FROM eav_attribute
      WHERE attribute_code LIKE "code_group"
      AND 'entity_type_id' = (
      SELECT entity_type_id
      FROM eav_entity_type
      WHERE entity_type_code = 'catalog_product'
      )
      )


      AND code_business.attribute_id = (
      SELECT attribute_id
      FROM eav_attribute
      WHERE attribute_code LIKE "code_business"
      AND 'entity_type_id' = (
      SELECT entity_type_id
      FROM eav_entity_type
      WHERE entity_type_code = 'catalog_product'
      )
      )


      What's wrong with my query?



      This is the Database diagram:



      Image







      magento-1.9





      share







      New contributor




      programming_amazing is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
      Check out our Code of Conduct.










      share







      New contributor




      programming_amazing is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
      Check out our Code of Conduct.








      share



      share






      New contributor




      programming_amazing is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
      Check out our Code of Conduct.









      asked 1 min ago









      programming_amazingprogramming_amazing

      52




      52




      New contributor




      programming_amazing is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
      Check out our Code of Conduct.





      New contributor





      programming_amazing is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
      Check out our Code of Conduct.






      programming_amazing is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
      Check out our Code of Conduct.






















          0






          active

          oldest

          votes











          Your Answer








          StackExchange.ready(function() {
          var channelOptions = {
          tags: "".split(" "),
          id: "479"
          };
          initTagRenderer("".split(" "), "".split(" "), channelOptions);

          StackExchange.using("externalEditor", function() {
          // Have to fire editor after snippets, if snippets enabled
          if (StackExchange.settings.snippets.snippetsEnabled) {
          StackExchange.using("snippets", function() {
          createEditor();
          });
          }
          else {
          createEditor();
          }
          });

          function createEditor() {
          StackExchange.prepareEditor({
          heartbeatType: 'answer',
          autoActivateHeartbeat: false,
          convertImagesToLinks: false,
          noModals: true,
          showLowRepImageUploadWarning: true,
          reputationToPostImages: null,
          bindNavPrevention: true,
          postfix: "",
          imageUploader: {
          brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
          contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
          allowUrls: true
          },
          onDemand: true,
          discardSelector: ".discard-answer"
          ,immediatelyShowMarkdownHelp:true
          });


          }
          });






          programming_amazing is a new contributor. Be nice, and check out our Code of Conduct.










          draft saved

          draft discarded


















          StackExchange.ready(
          function () {
          StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fmagento.stackexchange.com%2fquestions%2f259564%2fget-all-product-from-magento-sql-query%23new-answer', 'question_page');
          }
          );

          Post as a guest















          Required, but never shown

























          0






          active

          oldest

          votes








          0






          active

          oldest

          votes









          active

          oldest

          votes






          active

          oldest

          votes








          programming_amazing is a new contributor. Be nice, and check out our Code of Conduct.










          draft saved

          draft discarded


















          programming_amazing is a new contributor. Be nice, and check out our Code of Conduct.













          programming_amazing is a new contributor. Be nice, and check out our Code of Conduct.












          programming_amazing is a new contributor. Be nice, and check out our Code of Conduct.
















          Thanks for contributing an answer to Magento Stack Exchange!


          • Please be sure to answer the question. Provide details and share your research!

          But avoid



          • Asking for help, clarification, or responding to other answers.

          • Making statements based on opinion; back them up with references or personal experience.


          To learn more, see our tips on writing great answers.




          draft saved


          draft discarded














          StackExchange.ready(
          function () {
          StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fmagento.stackexchange.com%2fquestions%2f259564%2fget-all-product-from-magento-sql-query%23new-answer', 'question_page');
          }
          );

          Post as a guest















          Required, but never shown





















































          Required, but never shown














          Required, but never shown












          Required, but never shown







          Required, but never shown

































          Required, but never shown














          Required, but never shown












          Required, but never shown







          Required, but never shown







          Popular posts from this blog

          Alcázar de San Juan

          Griza ansero

          Heinkel He 51