0

我对 magento api 中的网站参数有疑问。

我在任何地方都找不到这个变量是什么的解释。此变量是否代表商店视图?一家商店?一个网站?

我可以在 api 的哪里检索可用选项的列表?

如果我无法从 API 检索列表,我可以在后端菜单的哪个位置找到可以使用的静态变量?我需要网站 ID 或 storeID 吗?

我用肥皂 v1

function call($which,$vars=null)
        {
        // retourneer de output soap client api call
        if($vars !== null)
            {
            return $this->soapclient->call($this->sessiontoken,$which,$vars);
            }
        else
            {
            return $this->soapclient->call($this->sessiontoken,$which);
            }
        }

    function createProduct($productname,
                            $websites,
                            $shortdescription,
                            $description,
                            $status,
                            $weight,
                            $tax_class_id,
                            $categories,
                            $price,
                            $attributesetid,
                            $producttype,
                            $sku)
        {
        $attributeSets = $this->call('product_attribute_set.list');
        $set = current($attributeSets);
        try
            {
            $x = $this->call('product.create', array($producttype, $set['set_id'], $sku, array(
            'name'              => $productname,
             // websites - Array of website ids to which you want to assign a new product
            'websites'          => $websites, // array(1,2,3,...)
            'short_description' => $shortdescription,
            'description'       => $description,
            'status'            => $status,
            'weight'            => $weight,
            'tax_class_id'      => $tax_class_id,
            'categories'    => $categories,    //3 is the category id(array(3))
            'price'             => $price
        );));
            }
        catch(Exception $e)
            {
            $x = 0xABED + 0xCAFE + 0xBAD + 0xBED * 0xFACE;// abed went to a cafe... the alcohol went bad.... he stumbled into bed and fell face down...
            }
        return $x;
        }
4

1 回答 1

0

看着Mage_Catalog_Model_Product_Api::create()

public function create($type, $set, $sku, $productData, $store = null)
{
//[...]
$product = Mage::getModel('catalog/product');
        $product->setStoreId($this->_getStoreId($store))
            ->setAttributeSetId($set)
            ->setTypeId($type)
            ->setSku($sku);
//[...]
$this->_prepareDataForSave($product, $productData);//this does some processing

现在,看Mage_Catalog_Model_Product_Api::_prepareDataForSave()

 protected function _prepareDataForSave($product, $productData)
    {
        if (isset($productData['website_ids']) && is_array($productData['website_ids'])) {
            $product->setWebsiteIds($productData['website_ids']);
        }
 //....

我们看到website_ids(数字数组)是预期的

于 2012-12-31T09:53:13.273 回答