Eav attribute type int which input to use












1















I am currently creating some product attributes and some of them should be of type integer but Magento doesn't offer any input type for integer values.



If I use 'input' => 'text' it seems that Magento parses it into int and if I enter a correct int value it's stored correctly. On the other hand, if I enter a string value like "abc" it's just stored as 0.

I am not sure whether it's a good practice to just use 'input' => 'text' or if it has many risks and there's a better way to handle those cases. What could be the risks of using text as an input method?



I don't really want to use varchar for them because they are clearly numbers and parsing them to int with a backend_model is not a good approach either in my opinion. And using 'input' => 'price' too, due to it's a decimal indication.



Update

Based on the comment of Alex is it okay to use combinations of 'input' and 'type' that are not used when you create a attribute from backend or what could be risks of that??










share|improve this question

























  • I think there are certain combinations of input and backend/frontend modles which are supported by the Magento backend and other's not. The question for me is, whether it is fine to use the combinations which are not supported by the backend attribute creation in update scripts or not.

    – Alex
    10 mins ago











  • The problem here is when you choose one of the input types from backend you cannot have integer values. Integers are used for selects and boolean inputs. For a input field where you can freely insert values you have to use text fields or price and neither of them are good choices in my opinion

    – Daniel
    6 mins ago
















1















I am currently creating some product attributes and some of them should be of type integer but Magento doesn't offer any input type for integer values.



If I use 'input' => 'text' it seems that Magento parses it into int and if I enter a correct int value it's stored correctly. On the other hand, if I enter a string value like "abc" it's just stored as 0.

I am not sure whether it's a good practice to just use 'input' => 'text' or if it has many risks and there's a better way to handle those cases. What could be the risks of using text as an input method?



I don't really want to use varchar for them because they are clearly numbers and parsing them to int with a backend_model is not a good approach either in my opinion. And using 'input' => 'price' too, due to it's a decimal indication.



Update

Based on the comment of Alex is it okay to use combinations of 'input' and 'type' that are not used when you create a attribute from backend or what could be risks of that??










share|improve this question

























  • I think there are certain combinations of input and backend/frontend modles which are supported by the Magento backend and other's not. The question for me is, whether it is fine to use the combinations which are not supported by the backend attribute creation in update scripts or not.

    – Alex
    10 mins ago











  • The problem here is when you choose one of the input types from backend you cannot have integer values. Integers are used for selects and boolean inputs. For a input field where you can freely insert values you have to use text fields or price and neither of them are good choices in my opinion

    – Daniel
    6 mins ago














1












1








1








I am currently creating some product attributes and some of them should be of type integer but Magento doesn't offer any input type for integer values.



If I use 'input' => 'text' it seems that Magento parses it into int and if I enter a correct int value it's stored correctly. On the other hand, if I enter a string value like "abc" it's just stored as 0.

I am not sure whether it's a good practice to just use 'input' => 'text' or if it has many risks and there's a better way to handle those cases. What could be the risks of using text as an input method?



I don't really want to use varchar for them because they are clearly numbers and parsing them to int with a backend_model is not a good approach either in my opinion. And using 'input' => 'price' too, due to it's a decimal indication.



Update

Based on the comment of Alex is it okay to use combinations of 'input' and 'type' that are not used when you create a attribute from backend or what could be risks of that??










share|improve this question
















I am currently creating some product attributes and some of them should be of type integer but Magento doesn't offer any input type for integer values.



If I use 'input' => 'text' it seems that Magento parses it into int and if I enter a correct int value it's stored correctly. On the other hand, if I enter a string value like "abc" it's just stored as 0.

I am not sure whether it's a good practice to just use 'input' => 'text' or if it has many risks and there's a better way to handle those cases. What could be the risks of using text as an input method?



I don't really want to use varchar for them because they are clearly numbers and parsing them to int with a backend_model is not a good approach either in my opinion. And using 'input' => 'price' too, due to it's a decimal indication.



Update

Based on the comment of Alex is it okay to use combinations of 'input' and 'type' that are not used when you create a attribute from backend or what could be risks of that??







magento2 magento2.2 attributes






share|improve this question















share|improve this question













share|improve this question




share|improve this question








edited 51 secs ago







Daniel

















asked 12 mins ago









DanielDaniel

729




729













  • I think there are certain combinations of input and backend/frontend modles which are supported by the Magento backend and other's not. The question for me is, whether it is fine to use the combinations which are not supported by the backend attribute creation in update scripts or not.

    – Alex
    10 mins ago











  • The problem here is when you choose one of the input types from backend you cannot have integer values. Integers are used for selects and boolean inputs. For a input field where you can freely insert values you have to use text fields or price and neither of them are good choices in my opinion

    – Daniel
    6 mins ago



















  • I think there are certain combinations of input and backend/frontend modles which are supported by the Magento backend and other's not. The question for me is, whether it is fine to use the combinations which are not supported by the backend attribute creation in update scripts or not.

    – Alex
    10 mins ago











  • The problem here is when you choose one of the input types from backend you cannot have integer values. Integers are used for selects and boolean inputs. For a input field where you can freely insert values you have to use text fields or price and neither of them are good choices in my opinion

    – Daniel
    6 mins ago

















I think there are certain combinations of input and backend/frontend modles which are supported by the Magento backend and other's not. The question for me is, whether it is fine to use the combinations which are not supported by the backend attribute creation in update scripts or not.

– Alex
10 mins ago





I think there are certain combinations of input and backend/frontend modles which are supported by the Magento backend and other's not. The question for me is, whether it is fine to use the combinations which are not supported by the backend attribute creation in update scripts or not.

– Alex
10 mins ago













The problem here is when you choose one of the input types from backend you cannot have integer values. Integers are used for selects and boolean inputs. For a input field where you can freely insert values you have to use text fields or price and neither of them are good choices in my opinion

– Daniel
6 mins ago





The problem here is when you choose one of the input types from backend you cannot have integer values. Integers are used for selects and boolean inputs. For a input field where you can freely insert values you have to use text fields or price and neither of them are good choices in my opinion

– Daniel
6 mins ago










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%2f258360%2feav-attribute-type-int-which-input-to-use%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%2f258360%2feav-attribute-type-int-which-input-to-use%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

Polycentropodidae

Magento 2 Error message: Invalid state change requested

Paulmy