Warning: file_get_contents(/data/phpspider/zhask/data//catemap/8/magento/5.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Php Magento关联产品选项_Php_Magento_Magento 1.4 - Fatal编程技术网

Php Magento关联产品选项

Php Magento关联产品选项,php,magento,magento-1.4,Php,Magento,Magento 1.4,我已将所有产品导入为可配置产品,并将其选项导入为简单产品类型,所有简单产品具有正确的大小属性,可配置产品具有正确的属性集 将产品选项与其产品关联的最佳方式是什么 我宁愿不要用SQL来做这件事,如果我能帮上忙的话,也不要手动做 提前感谢我一直认为这是不可能的使用如所解释的,例如 但谷歌很快就显示出有人显然是这样的。以下是论坛帖子中的相关代码: $this->proxy->call($this->session, 'catalog_product_link.assign',

我已将所有产品导入为可配置产品,并将其选项导入为简单产品类型,所有简单产品具有正确的大小属性,可配置产品具有正确的属性集

将产品选项与其产品关联的最佳方式是什么

我宁愿不要用SQL来做这件事,如果我能帮上忙的话,也不要手动做


提前感谢

我一直认为这是不可能的使用如所解释的,例如

但谷歌很快就显示出有人显然是这样的。以下是论坛帖子中的相关代码:

$this->proxy->call($this->session,
    'catalog_product_link.assign',
    array('configurable',
        $newConfigProdId, //This is the product ID of the configurable product
        $createdVariants, //This is an array of product IDs of simple products to associate to the configurable product
        array(ATTR_ID_COLOR, //This is an array of attribute IDs to create as superAttributes for the configurable product.
            ATTR_ID_SIZE //I've defined them as constants...
        )
    )
);

我一直认为这是不可能的使用解释,例如

但谷歌很快就显示出有人显然是这样的。以下是论坛帖子中的相关代码:

$this->proxy->call($this->session,
    'catalog_product_link.assign',
    array('configurable',
        $newConfigProdId, //This is the product ID of the configurable product
        $createdVariants, //This is an array of product IDs of simple products to associate to the configurable product
        array(ATTR_ID_COLOR, //This is an array of attribute IDs to create as superAttributes for the configurable product.
            ATTR_ID_SIZE //I've defined them as constants...
        )
    )
);

我理解你的问题,你想把简单的产品分配给它的“可配置的父产品”吗? 如果是这样,请查看Mage\u目录\u模型\u产品\u类型\u可配置模型。有一个方法save调用资源模型的方法saveProducts$mainProduct$productIds:

Mage::getResourceModel('catalog/product_type_configurable')
            ->saveProducts($this->getProduct($product), $productIds);

我理解你的问题,你想把简单的产品分配给它的“可配置的父产品”吗? 如果是这样,请查看Mage\u目录\u模型\u产品\u类型\u可配置模型。有一个方法save调用资源模型的方法saveProducts$mainProduct$productIds:

Mage::getResourceModel('catalog/product_type_configurable')
            ->saveProducts($this->getProduct($product), $productIds);

为了使$this正确工作,您能稍微扩展一下将代码放在哪里吗?我只想为每个可配置的产品创建一个简单的php文件,其中包含我的简单ProductID数组。如果它是单独的php文件,首先需要包含所有magento核心库,并启动应用程序Mage::app$mageRunCode、$mageRunType、$mageRunOptions,就像在index.php中一样,以便使用magento核心。在那之后写一些类似的东西:$configurableProducts=array'1'=>array1,2,3,2=>array4,5,6$model=Mage::getResourceModel'catalog/product_type_configurable';foreach$configurableProducts为$mainProductId=>$childProductsId{$model->saveProducts$mainProductId,$childProductsId;}为了使$this正确工作,请您稍微扩展一下该代码的位置好吗?我只想为每个可配置的产品创建一个简单的php文件,其中包含我的简单ProductID数组。如果它是单独的php文件,首先需要包含所有magento核心库,并启动应用程序Mage::app$mageRunCode、$mageRunType、$mageRunOptions,就像在index.php中一样,以便使用magento核心。在那之后写一些类似的东西:$configurableProducts=array'1'=>array1,2,3,2=>array4,5,6$model=Mage::getResourceModel'catalog/product_type_configurable';foreach$configurableProducts为$mainProductId=>$childProductsId{$model->saveProducts$mainProductId,$childProductsId;}