通过模块编辑magento数据库


Edit magento database through module

我对magento还很陌生,所以如果你觉得这很容易,我很抱歉。我正在为这个网站使用webkul市场。我有两组客户端:retailerdisplay,我正在努力使其成为这样,如果客户端是display,则其所有产品都将在only display上设置一个属性,否则该属性将设置在sellable

我正在模块的IndexController.php中运行我的功能,但我无法从数据库中调用我的产品。

产品的属性名为category,我将其创建为系统属性,而客户端的属性在costumer_entity表中称为group_id

为了调用目录中的产品,您必须通过它们的模型访问它们。

$products = Mage::getModel('catalog/product')->getCollection();

除此之外,您可以使用以下内容将过滤器添加到集合中:

$products ->addAttributeToSelect('sku')
        ->addAttributeToSelect('name')
        ->addAttributeToSelect('attribute_set_id')
        ->addAttributeToSelect('type_id');

如果你有可用的store_id,你可以像这个一样将store_id过滤器添加到集合中

$products ->addStoreFilter($store_id);

我希望我能帮助

F