VirtueMart Forum

VirtueMart 2 + 3 + 4 => Administration & Configuration => Topic started by: marvays on June 03, 2018, 22:17:38 PM

Title: XML FEED - if manufacturer
Post by: marvays on June 03, 2018, 22:17:38 PM
Hi. I am try create xml feed with gift. gift is 3 years warranty for specific manufacturer. What is bad on this code?

if ($product->virtuemart_manufacturer_id = 1) {
echo "
<GIFT>extended warranty for 3 years</GIFT>
";
}
Title: Re: XML FEED - if manufacturer
Post by: Studio 42 on June 04, 2018, 01:46:05 AM
if ($product->virtuemart_manufacturer_id = 1) {
Means that you set $product->virtuemart_manufacturer_id  to value 1.
Comparing two values is == not =
if ($product->virtuemart_manufacturer_id == 1) {
Is right
Title: Re: XML FEED - if manufacturer
Post by: marvays on June 04, 2018, 07:02:11 AM
thx i will try it.
PS: How if ($product-> ???? i can use for "if" ? . . . . . i know only "price"
Title: Re: XML FEED - if manufacturer
Post by: marvays on June 04, 2018, 07:11:42 AM
Quote from: Studio 42 on June 04, 2018, 01:46:05 AM
if ($product->virtuemart_manufacturer_id = 1) {
Means that you set $product->virtuemart_manufacturer_id  to value 1.
Comparing two values is == not =
if ($product->virtuemart_manufacturer_id == 1) {
Is right


not work :(
If I use == this warranty isnt anywhere. If I use only = i see warranty in all product. All is bad. I need show this info only on products with manufacturer, who have id 1
Title: Re: XML FEED - if manufacturer
Post by: Studio 42 on June 04, 2018, 11:43:37 AM
What is the ID of this manufacturer ?
Title: Re: XML FEED - if manufacturer
Post by: marvays on June 04, 2018, 14:34:30 PM
administrator/index.php?option=com_virtuemart&view=manufacturer
every manufacturers have name and ID. If I want to use the extended warranty only for this manufacturer . . . .
Title: Re: XML FEED - if manufacturer
Post by: Studio 42 on June 04, 2018, 17:56:02 PM
You have an old Vm 2, so you should perhaps update it and Joomla ?
Try
print("<pre>".print_r($product,true)."</pre>");
jexit();
And check if the virtuemart_manufacturer_id exist.
Perhaps VM2 back-end do not load manufacturer id ?
Title: Re: XML FEED - if manufacturer
Post by: Ghost on June 05, 2018, 09:39:43 AM
Don't know about VM2 but in VM3 virtuemart_manufacturer_id property on product is an array (because one product can have multiple manufacturers). So the code would be this:
if (in_array(1, $product->virtuemart_manufacturer_id))

Or, if you always use only 1 manufacturer per product,  you can check against first array element:
if ($product->virtuemart_manufacturer_id[0] == 1)
Title: Re: XML FEED - if manufacturer
Post by: marvays on June 05, 2018, 09:46:26 AM
work for me this:
if ($product->manufacturer == 'XXX') {
echo "
<GIFT>XXX</GIFT>
";
}

And now . . . can you into <GIFT>XXX</GIFT> prepare code . . . "10% form product prize"? I want type <GIFT>Gift worth 10 euros.</GIFT> . . . but 10 euro is 10% form product prze 100 euro. Understund me? But my english is bad :(
Title: Re: XML FEED - if manufacturer
Post by: Studio 42 on June 05, 2018, 11:40:15 AM
$product->prices['salesPrice'] is in Vm3 the final price
But use the code
print("<pre>".print_r($product,true)."</pre>");
jexit();
And check the result to show price