如何将自定义设置添加到Magento产品元页面?

如何将自定义设置添加到Magento产品元页面?,magento,magento-1.7,Magento,Magento 1.7,我是Magento的新手,今天才开始使用它。我需要为产品的Meta选项卡下的Admin面板添加一个自定义选项。我需要添加一个选项,管理员可以选择从生成的sitemap.xml文件中删除此产品 在wordpress中,这将通过自定义元字段或自定义设置字段实现 Magento中是否存在类似的功能,用于设置自定义设置,然后检索它们?我看到了一些关于自定义属性的内容,但它们似乎实际出现在主题和面板中,而不是按照我描述的方式工作 用户在下面发布了一个非常有用的代码片段,可以帮助您处理实际的站点地图(不包括

我是Magento的新手,今天才开始使用它。我需要为产品的Meta选项卡下的Admin面板添加一个自定义选项。我需要添加一个选项,管理员可以选择从生成的sitemap.xml文件中删除此产品

在wordpress中,这将通过自定义元字段或自定义设置字段实现

Magento中是否存在类似的功能,用于设置自定义设置,然后检索它们?我看到了一些关于自定义属性的内容,但它们似乎实际出现在主题和面板中,而不是按照我描述的方式工作

用户在下面发布了一个非常有用的代码片段,可以帮助您处理实际的站点地图(不包括部分)

所以我只需要弄清楚

如何向产品的元选项卡添加设置 如何在下面的代码中检索此设置值以便使用 第二部分应该非常简单,创建一个函数来获取设置为隐藏在sitemap.xml中的所有产品值,然后在下面的代码中使用它们

我的主要问题是将设置添加到产品管理页面的元信息区域,是否需要帮助

public function getCollection($storeId)
{
    $products = array();

    $store = Mage::app()->getStore($storeId);
    /* @var $store Mage_Core_Model_Store */

    if (!$store) {
        return false;
    }

    $urCondions = array(
        'e.entity_id=ur.product_id',
        'ur.category_id IS NULL',
        $this->_getWriteAdapter()->quoteInto('ur.store_id=?', $store->getId()),
        $this->_getWriteAdapter()->quoteInto('ur.is_system=?', 1),
    );
    $this->_select = $this->_getWriteAdapter()->select()
        ->from(array('e' => $this->getMainTable()), array($this->getIdFieldName()))
        ->join(
            array('w' => $this->getTable('catalog/product_website')),
            'e.entity_id=w.product_id',
            array()
        )
        ->where('w.website_id=?', $store->getWebsiteId())
        // --- exclude single product by its entity_id
        ->where('e.entity_id<>152')
        // --- exclude multiple products by their entity_id's
        // ->where('e.entity_id NOT IN (?)', array(152, 156))
        ->joinLeft(
            array('ur' => $this->getTable('core/url_rewrite')),
            join(' AND ', $urCondions),
            array('url' => 'request_path')
        );

    $this->_addFilter($storeId, 'visibility', Mage::getSingleton('catalog/product_visibility')->getVisibleInSiteIds(), 'in');
    $this->_addFilter($storeId, 'status', Mage::getSingleton('catalog/product_status')->getVisibleStatusIds(), 'in');

    $query = $this->_getWriteAdapter()->query($this->_select);
    while ($row = $query->fetch()) {
        $product = $this->_prepareProduct($row);
        $products[$product->getId()] = $product;
    }

    return $products;
}
让自己熟悉在magento中如何处理产品属性。要将元字段添加到产品中,首先需要。然后需要将此属性指定给产品的属性集。默认属性集就可以了。新字段现在将在productconfiguration中可见

要访问新属性,可以在产品对象上调用$product->getData'your_attribute'或$product->getYourAttribute