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?

How to motivate offshore teams and trust them to deliver?

Can Pao de Queijo, and similar foods, be kosher for Passover?

Why is black pepper both grey and black?

What are 'alternative tunings' of a guitar and why would you use them? Doesn't it make it more difficult to play?

How can players work together to take actions that are otherwise impossible?

What is the longest distance a 13th-level monk can jump while attacking on the same turn?

Java 8 stream max() function argument type Comparator vs Comparable

What is a Meta algorithm?

What are the motives behind Cersei's orders given to Bronn?

When -s is used with third person singular. What's its use in this context?

Is there a Spanish version of "dot your i's and cross your t's" that includes the letter 'ñ'?

Is there a "higher Segal conjecture"?

Antler Helmet: Can it work?

Should I discuss the type of campaign with my players?

Bonus calculation: Am I making a mountain out of a molehill?

How to draw this diagram using TikZ package?

What's the purpose of writing one's academic bio in 3rd person?

What is this single-engine low-wing propeller plane?

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

Did Xerox really develop the first LAN?

Examples of mediopassive verb constructions

Is there a documented rationale why the House Ways and Means chairman can demand tax info?

Withdrew £2800, but only £2000 shows as withdrawn on online banking; what are my obligations?

Right-skewed distribution with mean equals to mode?



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
    yesterday











  • @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
    yesterday

















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
    yesterday











  • @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
    yesterday













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 17 hours ago









HelgeB

3,2781323




3,2781323










asked yesterday









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
    yesterday











  • @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
    yesterday

















  • 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
    yesterday











  • @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
    yesterday
















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
yesterday





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
yesterday













@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
yesterday





@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
yesterday










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 17 hours ago

























        answered 17 hours ago









        HelgeBHelgeB

        3,2781323




        3,2781323



























            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

            Category:9 (number) SubcategoriesMedia in category "9 (number)"Navigation menuUpload mediaGND ID: 4485639-8Library of Congress authority ID: sh85091979ReasonatorScholiaStatistics

            Circuit construction for execution of conditional statements using least significant bitHow are two different registers being used as “control”?How exactly is the stated composite state of the two registers being produced using the $R_zz$ controlled rotations?Efficiently performing controlled rotations in HHLWould this quantum algorithm implementation work?How to prepare a superposed states of odd integers from $1$ to $sqrtN$?Why is this implementation of the order finding algorithm not working?Circuit construction for Hamiltonian simulationHow can I invert the least significant bit of a certain term of a superposed state?Implementing an oracleImplementing a controlled sum operation

            Magento 2 “No Payment Methods” in Admin New OrderHow to integrate Paypal Express Checkout with the Magento APIMagento 1.5 - Sales > Order > edit order and shipping methods disappearAuto Invoice Check/Money Order Payment methodAdd more simple payment methods?Shipping methods not showingWhat should I do to change payment methods if changing the configuration has no effects?1.9 - No Payment Methods showing upMy Payment Methods not Showing for downloadable/virtual product when checkout?Magento2 API to access internal payment methodHow to call an existing payment methods in the registration form?