Is it possible to reduce the default varchar size in catalog_product_flat? (M2)





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







3















I have a seemingly common problem. With too many custom attributes that are necessary and no way to change them in a way that would make the use of the default flat catalog possible I am searching for another solution.



Magento by default sets the size of attributes stored as varchar in flat tables to 255, which in my case is unnecessarily long. I could totally live with a size of 65, which would also bypass the MySQL limitation problem.



I have found hints on how to adjust Magento 1 in that way but not a single clue on how to do that with Magento 2. What I would like to know is:




  • Wether or not this is possible at all, e.g. where to find the sizing in the code,

  • And if it is, what kind of problems could emerge doing it.


UPDATE:
I have found a way to do it, which seems really convenient. I added



if ($fieldName != "description" && $columnLength > 200){
$columnLength = 65;
}


right before



$table->addColumn($fieldName, $fieldProp['type'], $columnLength, $columnDefinition, $columnComment);


in Magento/Catalog/Model/Indexer/Product/Flat/FlatTableBuilder



Creating the flat table now works like a charm, but my second question remains: What kind of implications could this have?










share|improve this question

























  • I did actually do exactly what you suggested above in UPDATE for exact same reasons (flat catalogue wouldnt work) however I had wiered issues, I think related products stopped showing prices and names in some cases. I didnt have loads of time to debug at the time (may have been a simple fix) so reverted but yeah I had issues doing that although reindex worked with flat catalogue after the mod.

    – harri
    yesterday




















3















I have a seemingly common problem. With too many custom attributes that are necessary and no way to change them in a way that would make the use of the default flat catalog possible I am searching for another solution.



Magento by default sets the size of attributes stored as varchar in flat tables to 255, which in my case is unnecessarily long. I could totally live with a size of 65, which would also bypass the MySQL limitation problem.



I have found hints on how to adjust Magento 1 in that way but not a single clue on how to do that with Magento 2. What I would like to know is:




  • Wether or not this is possible at all, e.g. where to find the sizing in the code,

  • And if it is, what kind of problems could emerge doing it.


UPDATE:
I have found a way to do it, which seems really convenient. I added



if ($fieldName != "description" && $columnLength > 200){
$columnLength = 65;
}


right before



$table->addColumn($fieldName, $fieldProp['type'], $columnLength, $columnDefinition, $columnComment);


in Magento/Catalog/Model/Indexer/Product/Flat/FlatTableBuilder



Creating the flat table now works like a charm, but my second question remains: What kind of implications could this have?










share|improve this question

























  • I did actually do exactly what you suggested above in UPDATE for exact same reasons (flat catalogue wouldnt work) however I had wiered issues, I think related products stopped showing prices and names in some cases. I didnt have loads of time to debug at the time (may have been a simple fix) so reverted but yeah I had issues doing that although reindex worked with flat catalogue after the mod.

    – harri
    yesterday
















3












3








3








I have a seemingly common problem. With too many custom attributes that are necessary and no way to change them in a way that would make the use of the default flat catalog possible I am searching for another solution.



Magento by default sets the size of attributes stored as varchar in flat tables to 255, which in my case is unnecessarily long. I could totally live with a size of 65, which would also bypass the MySQL limitation problem.



I have found hints on how to adjust Magento 1 in that way but not a single clue on how to do that with Magento 2. What I would like to know is:




  • Wether or not this is possible at all, e.g. where to find the sizing in the code,

  • And if it is, what kind of problems could emerge doing it.


UPDATE:
I have found a way to do it, which seems really convenient. I added



if ($fieldName != "description" && $columnLength > 200){
$columnLength = 65;
}


right before



$table->addColumn($fieldName, $fieldProp['type'], $columnLength, $columnDefinition, $columnComment);


in Magento/Catalog/Model/Indexer/Product/Flat/FlatTableBuilder



Creating the flat table now works like a charm, but my second question remains: What kind of implications could this have?










share|improve this question
















I have a seemingly common problem. With too many custom attributes that are necessary and no way to change them in a way that would make the use of the default flat catalog possible I am searching for another solution.



Magento by default sets the size of attributes stored as varchar in flat tables to 255, which in my case is unnecessarily long. I could totally live with a size of 65, which would also bypass the MySQL limitation problem.



I have found hints on how to adjust Magento 1 in that way but not a single clue on how to do that with Magento 2. What I would like to know is:




  • Wether or not this is possible at all, e.g. where to find the sizing in the code,

  • And if it is, what kind of problems could emerge doing it.


UPDATE:
I have found a way to do it, which seems really convenient. I added



if ($fieldName != "description" && $columnLength > 200){
$columnLength = 65;
}


right before



$table->addColumn($fieldName, $fieldProp['type'], $columnLength, $columnDefinition, $columnComment);


in Magento/Catalog/Model/Indexer/Product/Flat/FlatTableBuilder



Creating the flat table now works like a charm, but my second question remains: What kind of implications could this have?







flat-catalog eav-attributes flat-indexer varchar






share|improve this question















share|improve this question













share|improve this question




share|improve this question








edited Dec 27 '18 at 16:38







Tobi

















asked Dec 27 '18 at 16:08









TobiTobi

163




163













  • I did actually do exactly what you suggested above in UPDATE for exact same reasons (flat catalogue wouldnt work) however I had wiered issues, I think related products stopped showing prices and names in some cases. I didnt have loads of time to debug at the time (may have been a simple fix) so reverted but yeah I had issues doing that although reindex worked with flat catalogue after the mod.

    – harri
    yesterday





















  • I did actually do exactly what you suggested above in UPDATE for exact same reasons (flat catalogue wouldnt work) however I had wiered issues, I think related products stopped showing prices and names in some cases. I didnt have loads of time to debug at the time (may have been a simple fix) so reverted but yeah I had issues doing that although reindex worked with flat catalogue after the mod.

    – harri
    yesterday



















I did actually do exactly what you suggested above in UPDATE for exact same reasons (flat catalogue wouldnt work) however I had wiered issues, I think related products stopped showing prices and names in some cases. I didnt have loads of time to debug at the time (may have been a simple fix) so reverted but yeah I had issues doing that although reindex worked with flat catalogue after the mod.

– harri
yesterday







I did actually do exactly what you suggested above in UPDATE for exact same reasons (flat catalogue wouldnt work) however I had wiered issues, I think related products stopped showing prices and names in some cases. I didnt have loads of time to debug at the time (may have been a simple fix) so reverted but yeah I had issues doing that although reindex worked with flat catalogue after the mod.

– harri
yesterday












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


}
});














draft saved

draft discarded


















StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fmagento.stackexchange.com%2fquestions%2f255982%2fis-it-possible-to-reduce-the-default-varchar-size-in-catalog-product-flat-m2%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
















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%2f255982%2fis-it-possible-to-reduce-the-default-varchar-size-in-catalog-product-flat-m2%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

What other Star Trek series did the main TNG cast show up in?

Berlina muro

Berlina aerponto