0

I'm using this extension - http://www.magentocommerce.com/magento-connect/sort-by-date.html , which orders products by date (specifically by created_at eav attribute). Basically all it does is adds one more sort type like so:

$installer->startSetup();

    $prodEntityTypeId = $installer->getEntityTypeId('catalog_product');
    $installer->updateAttribute($prodEntityTypeId, 'created_at', 'frontend_label', 'Date created');
    $installer->updateAttribute($prodEntityTypeId, 'created_at', 'used_for_sort_by', 1);

$installer->endSetup();

Is there any way to show this attribute in admin area and be able to edit it? (to change order of some products) To implement this, I was trying to edit its params eav_attributes, but without success – the field is not visible in "edit product" page.

EDIT: I gave up, created a custom date attribute and fetched data in it from created_at.

1

To do this you need to add the attribute to the correct group. This can be done in two ways.

  1. Via the admin section, under the Attribute Set section. Here you drap and drop the attributes into the desired groups,
  2. Via another set-up script,

Since you already have the attribute you can update the groups value for it via:

$installer->updateAttribute(
    Mage_Catalog_Model_Product::ENTITY,
    'your_attribtue_code',
    'group',
    'General' //General group is the first tab on the admin product edit page
);
0

Just in case anyone still need to show created_at attribute in product edit form. I have added this code to the install script:

$installer = $this;
$installer->startSetup();
$prodEntityTypeId = $installer->getEntityTypeId('catalog_product');
$installer->updateAttribute(
    $prodEntityTypeId,
    'created_at',
    'group',
    'General' //General group is the first tab on the admin product edit page
);

$installer->updateAttribute(
    $prodEntityTypeId,
    'created_at',
    'is_visible',
    1 
);
$installer->endSetup();

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.