add new column to catalog product entity table Planned maintenance scheduled April 17/18, 2019 at 00:00UTC (8:00pm US/Eastern) Announcing the arrival of Valued Associate #679: Cesar Manara Unicorn Meta Zoo #1: Why another podcast?How to create Catalog attribute in Magento 2 Using Upgrade ScriptAdd new column to an EAV table `catalog_product_entity`magento 2 - How to add new column to table customer_grid_flatMagento2 custom collection invalid method exceptionMagento 2.1 Create a filter in the product grid by new attributeNeed to add decimal column in existing tableHow to add new column and custom attribute in order email template in Magento 1.9.3?Magento Get Attribute values Collection by filterAdd new column to individual options?Custom column in Product Grid not being filtered?How to Filter a Custom Column in Product Listing?

Compare a given version number in the form major.minor.build.patch and see if one is less than the other

Is "Reachable Object" really an NP-complete problem?

If my PI received research grants from a company to be able to pay my postdoc salary, did I have a potential conflict interest too?

Using et al. for a last / senior author rather than for a first author

What is homebrew?

また usage in a dictionary

How to find all the available tools in mac terminal?

How does the math work when buying airline miles?

How come Sam didn't become Lord of Horn Hill?

Where are Serre’s lectures at Collège de France to be found?

For a new assistant professor in CS, how to build/manage a publication pipeline

Delete nth line from bottom

Maximum summed powersets with non-adjacent items

Denied boarding although I have proper visa and documentation. To whom should I make a complaint?

What's the meaning of "fortified infraction restraint"?

How do I make this wiring inside cabinet safer? (Pic)

If u is orthogonal to both v and w, and u not equal to 0, argue that u is not in the span of v and w. (

Trademark violation for app?

Why are there no cargo aircraft with "flying wing" design?

What are the out-of-universe reasons for the references to Toby Maguire-era Spider-Man in ITSV

Can anything be seen from the center of the Boötes void? How dark would it be?

Crossing US/Canada Border for less than 24 hours

How to convince students of the implication truth values?

Is there such thing as an Availability Group failover trigger?



add new column to catalog product entity table



Planned maintenance scheduled April 17/18, 2019 at 00:00UTC (8:00pm US/Eastern)
Announcing the arrival of Valued Associate #679: Cesar Manara
Unicorn Meta Zoo #1: Why another podcast?How to create Catalog attribute in Magento 2 Using Upgrade ScriptAdd new column to an EAV table `catalog_product_entity`magento 2 - How to add new column to table customer_grid_flatMagento2 custom collection invalid method exceptionMagento 2.1 Create a filter in the product grid by new attributeNeed to add decimal column in existing tableHow to add new column and custom attribute in order email template in Magento 1.9.3?Magento Get Attribute values Collection by filterAdd new column to individual options?Custom column in Product Grid not being filtered?How to Filter a Custom Column in Product Listing?



.everyoneloves__top-leaderboard:empty,.everyoneloves__mid-leaderboard:empty,.everyoneloves__bot-mid-leaderboard:empty margin-bottom:0;








0















I add new column to catalog_product_entity. so when i want to add new filter to collection i get this error
The "user_id" attribute name is invalid. Reset the name and try again.



$subject->getCollection()->addFieldToFilter('user_id', array('eq' => '2'))









share|improve this question
























  • There may be two issues casuing this problem: You didn't add the column as eav attribute with backend_type = static (missing entry in eav_attribute table for attribute user_id) or the old DDL whithout your new column is cached (in this case try to flush the ddl cache: bin/magento cache:flush db_ddl)

    – HelgeB
    Apr 14 at 9:33











  • @HelgeB how i can add column as static attribute ? can you give me more detail . for secund issue i clear cache and update and compile

    – gh darvishani
    Apr 14 at 9:57

















0















I add new column to catalog_product_entity. so when i want to add new filter to collection i get this error
The "user_id" attribute name is invalid. Reset the name and try again.



$subject->getCollection()->addFieldToFilter('user_id', array('eq' => '2'))









share|improve this question
























  • There may be two issues casuing this problem: You didn't add the column as eav attribute with backend_type = static (missing entry in eav_attribute table for attribute user_id) or the old DDL whithout your new column is cached (in this case try to flush the ddl cache: bin/magento cache:flush db_ddl)

    – HelgeB
    Apr 14 at 9:33











  • @HelgeB how i can add column as static attribute ? can you give me more detail . for secund issue i clear cache and update and compile

    – gh darvishani
    Apr 14 at 9:57













0












0








0


0






I add new column to catalog_product_entity. so when i want to add new filter to collection i get this error
The "user_id" attribute name is invalid. Reset the name and try again.



$subject->getCollection()->addFieldToFilter('user_id', array('eq' => '2'))









share|improve this question
















I add new column to catalog_product_entity. so when i want to add new filter to collection i get this error
The "user_id" attribute name is invalid. Reset the name and try again.



$subject->getCollection()->addFieldToFilter('user_id', array('eq' => '2'))






magento2 database product-attribute catalog






share|improve this question















share|improve this question













share|improve this question




share|improve this question








edited 2 days ago









HelgeB

3,3281323




3,3281323










asked Apr 14 at 7:19









gh darvishanigh darvishani

340217




340217












  • There may be two issues casuing this problem: You didn't add the column as eav attribute with backend_type = static (missing entry in eav_attribute table for attribute user_id) or the old DDL whithout your new column is cached (in this case try to flush the ddl cache: bin/magento cache:flush db_ddl)

    – HelgeB
    Apr 14 at 9:33











  • @HelgeB how i can add column as static attribute ? can you give me more detail . for secund issue i clear cache and update and compile

    – gh darvishani
    Apr 14 at 9:57

















  • There may be two issues casuing this problem: You didn't add the column as eav attribute with backend_type = static (missing entry in eav_attribute table for attribute user_id) or the old DDL whithout your new column is cached (in this case try to flush the ddl cache: bin/magento cache:flush db_ddl)

    – HelgeB
    Apr 14 at 9:33











  • @HelgeB how i can add column as static attribute ? can you give me more detail . for secund issue i clear cache and update and compile

    – gh darvishani
    Apr 14 at 9:57
















There may be two issues casuing this problem: You didn't add the column as eav attribute with backend_type = static (missing entry in eav_attribute table for attribute user_id) or the old DDL whithout your new column is cached (in this case try to flush the ddl cache: bin/magento cache:flush db_ddl)

– HelgeB
Apr 14 at 9:33





There may be two issues casuing this problem: You didn't add the column as eav attribute with backend_type = static (missing entry in eav_attribute table for attribute user_id) or the old DDL whithout your new column is cached (in this case try to flush the ddl cache: bin/magento cache:flush db_ddl)

– HelgeB
Apr 14 at 9:33













@HelgeB how i can add column as static attribute ? can you give me more detail . for secund issue i clear cache and update and compile

– gh darvishani
Apr 14 at 9:57





@HelgeB how i can add column as static attribute ? can you give me more detail . for secund issue i clear cache and update and compile

– gh darvishani
Apr 14 at 9:57










1 Answer
1






active

oldest

votes


















1














If you have added the column user_id manually to the table catalog_product_entity you can use the following way to filter your product collection:



$subject->getCollection()->getSelect()->where('user_id = 2');


or



$subject->getCollection()->getSelect()->where('e.user_id = 2'); 
//e is the reference for the table catalog_product_entity in the default product collection


That should work, beacuse this creates the SQL statement whithout checking if an attribute exists like the method addFieldToFilter does.



But it's not a good practice to alter core entity tables and add columns that way.



I would rather suggest to create a product attribute user_id of type integer and then your code with addFieldToFilter should work, without adding a column to catalog_product_entity.
If you really want / need the column in catalog_product_entity for whatever reason you should at least create a product attribute user_id of type static and then you can use your code with addFieldToFilter too.



An example how to create product attributes programmatically can be found here
How to create Catalog attribute in Magento 2 Using Upgrade Script



You have to set the correct type for your attribute ('type' => 'int' for an integer attribute or 'type' => 'static' if you want to use your added column)



There are also a lot of other examples for attribute creation if you google for it.






share|improve this answer

























    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
    );



    );













    draft saved

    draft discarded


















    StackExchange.ready(
    function ()
    StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fmagento.stackexchange.com%2fquestions%2f270011%2fadd-new-column-to-catalog-product-entity-table%23new-answer', 'question_page');

    );

    Post as a guest















    Required, but never shown

























    1 Answer
    1






    active

    oldest

    votes








    1 Answer
    1






    active

    oldest

    votes









    active

    oldest

    votes






    active

    oldest

    votes









    1














    If you have added the column user_id manually to the table catalog_product_entity you can use the following way to filter your product collection:



    $subject->getCollection()->getSelect()->where('user_id = 2');


    or



    $subject->getCollection()->getSelect()->where('e.user_id = 2'); 
    //e is the reference for the table catalog_product_entity in the default product collection


    That should work, beacuse this creates the SQL statement whithout checking if an attribute exists like the method addFieldToFilter does.



    But it's not a good practice to alter core entity tables and add columns that way.



    I would rather suggest to create a product attribute user_id of type integer and then your code with addFieldToFilter should work, without adding a column to catalog_product_entity.
    If you really want / need the column in catalog_product_entity for whatever reason you should at least create a product attribute user_id of type static and then you can use your code with addFieldToFilter too.



    An example how to create product attributes programmatically can be found here
    How to create Catalog attribute in Magento 2 Using Upgrade Script



    You have to set the correct type for your attribute ('type' => 'int' for an integer attribute or 'type' => 'static' if you want to use your added column)



    There are also a lot of other examples for attribute creation if you google for it.






    share|improve this answer





























      1














      If you have added the column user_id manually to the table catalog_product_entity you can use the following way to filter your product collection:



      $subject->getCollection()->getSelect()->where('user_id = 2');


      or



      $subject->getCollection()->getSelect()->where('e.user_id = 2'); 
      //e is the reference for the table catalog_product_entity in the default product collection


      That should work, beacuse this creates the SQL statement whithout checking if an attribute exists like the method addFieldToFilter does.



      But it's not a good practice to alter core entity tables and add columns that way.



      I would rather suggest to create a product attribute user_id of type integer and then your code with addFieldToFilter should work, without adding a column to catalog_product_entity.
      If you really want / need the column in catalog_product_entity for whatever reason you should at least create a product attribute user_id of type static and then you can use your code with addFieldToFilter too.



      An example how to create product attributes programmatically can be found here
      How to create Catalog attribute in Magento 2 Using Upgrade Script



      You have to set the correct type for your attribute ('type' => 'int' for an integer attribute or 'type' => 'static' if you want to use your added column)



      There are also a lot of other examples for attribute creation if you google for it.






      share|improve this answer



























        1












        1








        1







        If you have added the column user_id manually to the table catalog_product_entity you can use the following way to filter your product collection:



        $subject->getCollection()->getSelect()->where('user_id = 2');


        or



        $subject->getCollection()->getSelect()->where('e.user_id = 2'); 
        //e is the reference for the table catalog_product_entity in the default product collection


        That should work, beacuse this creates the SQL statement whithout checking if an attribute exists like the method addFieldToFilter does.



        But it's not a good practice to alter core entity tables and add columns that way.



        I would rather suggest to create a product attribute user_id of type integer and then your code with addFieldToFilter should work, without adding a column to catalog_product_entity.
        If you really want / need the column in catalog_product_entity for whatever reason you should at least create a product attribute user_id of type static and then you can use your code with addFieldToFilter too.



        An example how to create product attributes programmatically can be found here
        How to create Catalog attribute in Magento 2 Using Upgrade Script



        You have to set the correct type for your attribute ('type' => 'int' for an integer attribute or 'type' => 'static' if you want to use your added column)



        There are also a lot of other examples for attribute creation if you google for it.






        share|improve this answer















        If you have added the column user_id manually to the table catalog_product_entity you can use the following way to filter your product collection:



        $subject->getCollection()->getSelect()->where('user_id = 2');


        or



        $subject->getCollection()->getSelect()->where('e.user_id = 2'); 
        //e is the reference for the table catalog_product_entity in the default product collection


        That should work, beacuse this creates the SQL statement whithout checking if an attribute exists like the method addFieldToFilter does.



        But it's not a good practice to alter core entity tables and add columns that way.



        I would rather suggest to create a product attribute user_id of type integer and then your code with addFieldToFilter should work, without adding a column to catalog_product_entity.
        If you really want / need the column in catalog_product_entity for whatever reason you should at least create a product attribute user_id of type static and then you can use your code with addFieldToFilter too.



        An example how to create product attributes programmatically can be found here
        How to create Catalog attribute in Magento 2 Using Upgrade Script



        You have to set the correct type for your attribute ('type' => 'int' for an integer attribute or 'type' => 'static' if you want to use your added column)



        There are also a lot of other examples for attribute creation if you google for it.







        share|improve this answer














        share|improve this answer



        share|improve this answer








        edited 2 days ago

























        answered 2 days ago









        HelgeBHelgeB

        3,3281323




        3,3281323



























            draft saved

            draft discarded
















































            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%2f270011%2fadd-new-column-to-catalog-product-entity-table%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

            Sum ergo cogito? 1 nng

            419 nièngy_Soadمي 19bal1.5o_g

            Queiggey Chernihivv 9NnOo i Zw X QqKk LpB