使用API​​文章

时间:2018-08-09 11:38:34

标签: shopware

我已经使用shopware的api创建了一种产品。

参考:https://developers.shopware.com/developers-guide/rest-api/api-resource-article/

此产品(文章)在“项目->购物软件概述”中列出。但是,当我编辑此产品并尝试预览该产品(文章)时,它的外观不显示在前面。表明 : 不幸的是,该产品不再可用。  enter image description here

有人可以帮我为什么这个产品没有出现在前面吗?我想在前面显示我使用插件中的API创建的文章。

下面是我用于在商品中插入商品数据的数组。

$client->post('articles', 
    array(
        'name'             => 'Damen Organic T-Shirt',
        'description'      => 'Description',
        'descriptionLong' => 'Test Description',
        'active'           => 1,
        'taxId'            => 1,
        'metaTitle'        => '',
        'keywords'         => '',
        'changetime'       => date("Y-m-d H:i:s"),
        'notification'     => 0,
        'supplier'         => 'Shirtee',
        'categories'       => 'Shopware',
        'mainDetail'       => array(
            'number'   => 'MO1C38Q',
            'inStock'  => 1,
            'weight'   => '1.000',
            'position' => '1',
            'width'    => null,
            'height'   => null,
        'attribute' => array(
            'attr1' => '',
        ),
        'prices' => array(
            array(
                'customerGroupKey' => 'EK',
                'price'            => 50,
            ),
        ),
    ),
    'images'            => array(
        'link' => 'test.png'
    ),
    'configuratorSet'   => array(
        'groups' => array(
            array(
                'name'    => 'Size',
                'options' => 'M'
            ),
            array(
                'name'    => 'Color',
                'options' => 'Green'
            ),
        )
    )
));

您的回答将真正帮助我。

1 个答案:

答案 0 :(得分:0)

example所示,必须在active => true内传递mainDetail

    $minimalTestArticle = array(
    'name' => 'Sport Shoes',
    'active' => true,
    'tax' => 19,
    'supplier' => 'Sport Shoes Inc.',
    'categories' => array(
        array('id' => 15),
    ),
    'mainDetail' => array(
        'number' => 'turn',
        'active' => true,
        'prices' => array(
            array(
                'customerGroupKey' => 'EK',
                'price' => 999,
            ),
        )
    ),
);

$client->post('articles', $minimalTestArticle);

以下是您可以在engine/Shopware/Bundle/StoreFrontBundle/Service/Core/ProductNumberService.php -> isNumberAvailable

中找到的查询
SELECT variant.ordernumber FROM s_articles_details variant INNER JOIN s_articles product ON product.id = variant.articleID AND variant.active = 1 WHERE (variant.ordernumber = 'number') AND ((variant.laststock * variant.instock) >= (variant.laststock * variant.minpurchase)) LIMIT 1

此外,如果要创建每个变体,则需要为其设置active => true