1

How do you grab text fields from the Magento ORM back end?

Such as :

($_product->getCaseMeasurement()) ? $_product->getCaseMeasurement() : '';

Which grabs a text field of attribute code "case_measurement" or attribute label "Case Measurement"

If I had a text field of attribute code "clasp" and attribute label "Clasp".

8
  • Do you want the value of the attribute "clasp"? Commented Aug 29, 2018 at 14:08
  • Yes, the value of attribute clasp.
    – Shay Maor
    Commented Aug 29, 2018 at 14:11
  • Just use $_product->getClasp(); Commented Aug 29, 2018 at 14:13
  • I figure it's ($_product->getClasp()) ? $_product->getClasp() : '' but would like to confirm
    – Shay Maor
    Commented Aug 29, 2018 at 14:13
  • If it is worked for you, I have written as an answer ,please accept so that other can benefited . Commented Aug 29, 2018 at 14:25

1 Answer 1

1

To grabs a text field of product attribute with code clasp and product object is $_product use the below code to get value:

$clasp_value = $_product->getClasp()!=NULL?$_product->getClasp():'';
4
  • It didn't work for label Movement and attribute code movement... I used ($_product->getMovement()) ? $_product->getMovement() : ''; ($_product->getMovement()) works the same as != NULL Worked for everything else
    – Shay Maor
    Commented Aug 29, 2018 at 19:01
  • It worked for all other fields
    – Shay Maor
    Commented Aug 29, 2018 at 20:16
  • I think I found the issue.
    – Shay Maor
    Commented Aug 30, 2018 at 14:35
  • You will not get the attribute label of the the product object. Anyway whats the issue? Commented Aug 30, 2018 at 14:51

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.