0

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')
    ->setStoreId(Mage::app()->getStore()->getId())
    ->addCategoryFilter($category)
    ->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?

2
  • No 57 is product id? and what is the data in model_pn_line? Nov 21, 2016 at 7:18
  • no 57 is the attribute value
    – Mujahidh
    Nov 21, 2016 at 7:23

1 Answer 1

2

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.

1
  • yes, i added integer number to Input Validation for Store Owner filed on attribute.Thank you.
    – Mujahidh
    Nov 21, 2016 at 7:20

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.