PutOfferVariantRequest - documentation
Closed this issue · 3 comments
Hello
How to create instance of this class: PutOfferVariantRequest ?
I have some details wrong and it does not work.
Hi @RG-1
I suspect that you have a problem with second argument. I'll use short example to make things clear:
use Imper86\AllegroApi\Rest\Model\Collection\StringCollection;
use Imper86\AllegroApi\Rest\Model\Request\OfferVariants\ParameterModel\Offer;
use Imper86\AllegroApi\Rest\Model\Request\OfferVariants\ParameterModel\OfferCollection;
use Imper86\AllegroApi\Rest\Model\Request\OfferVariants\PutOfferVariantRequest;
$offer1 = new Offer('3124213213', 'collorpattern_1');
$offer2 = new Offer('3124213312', 'collorpattern_1');
$offerCollection = new OfferCollection();
$offerCollection->add($offer1);
$offerCollection->add($offer2);
$request = new PutOfferVariantRequest(
$variantSetUuid, //generate new or use existing one
$offerCollection,
'Name of variant set',
true, //use color pattern or not
new StringCollection(['paramid'])
);
After creatings request object like that you can just use it in sendRequest method in RestClient object.
Now it works perfectly.
Thank you very much for your help.
:-)
There is small typo in your example: offers must have unique values of parameters.
$offer1 = new Offer('3124213213', 'collorpattern_1'); // e.g. red
$offer2 = new Offer('3124213312', 'collorpattern_2'); // e.g. blue
@RG-1 of course it depends on what you want to do :). If you have the same color pattern on two offers you can still split them with parameter you give in the last argument of PutOfferVariantRequest constructor. Most standard use case for this is clothes/shoes - you have one model with different sizes :)