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

            Get product attribute by attribute group code in magento 2get product attribute by product attribute group in magento 2Magento 2 Log Bundle Product Data in List Page?How to get all product attribute of a attribute group of Default attribute set?Magento 2.1 Create a filter in the product grid by new attributeMagento 2 : Get Product Attribute values By GroupMagento 2 How to get all existing values for one attributeMagento 2 get custom attribute of a single product inside a pluginMagento 2.3 How to get all the Multi Source Inventory (MSI) locations collection in custom module?Magento2: how to develop rest API to get new productsGet product attribute by attribute group code ( [attribute_group_code] ) in magento 2

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

            Magento 2.3: How do i solve this, Not registered handle, on custom form?How can i rewrite TierPrice Block in Magento2magento 2 captcha not rendering if I override layout xmlmain.CRITICAL: Plugin class doesn't existMagento 2 : Problem while adding custom button order view page?Magento 2.2.5: Overriding Admin Controller sales/orderMagento 2.2.5: Add, Update and Delete existing products Custom OptionsMagento 2.3 : File Upload issue in UI Component FormMagento2 Not registered handleHow to configured Form Builder Js in my custom magento 2.3.0 module?Magento 2.3. How to create image upload field in an admin form