I created product attribute called model_pn_line and added the values for this attribute during product adding.

My product collection code is like below.

$category = Mage::getModel('catalog/category')->load($_product ->getId());
$productslist = Mage::getResourceModel('catalog/product_collection')
    ->addAttributeToSort('model_pn_line', 'asc');

The out put is like below. enter image description here

My Question is how the 6 coming after No 57?

  • No 57 is product id? and what is the data in model_pn_line? – Prashant Valanda Nov 21 '16 at 7:18
  • no 57 is the attribute value – Mujahidh Nov 21 '16 at 7:23

I'm going to take a guess here and say that your attribute has the type text (or varchar or anything else that's not a number).
For text fields the sorting is done alphabetically. And based on your screenshot it seams to work perfectly because the string 57 is "smaller" than the string 6.
If your attribute should behave as an integer then it should have the type int.

|improve this answer|||||
  • yes, i added integer number to Input Validation for Store Owner filed on attribute.Thank you. – Mujahidh Nov 21 '16 at 7:20

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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