Author Topic: XML FEED - if manufacturer  (Read 258 times)

marvays

  • Jr. Member
  • **
  • Posts: 93
    • http://marvays.cz
  • Skype Name: marvays
XML FEED - if manufacturer
« 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?

Code: [Select]
if ($product->virtuemart_manufacturer_id = 1) {
echo "
<GIFT>extended warranty for 3 years</GIFT>
";
}

Studio 42

  • Contributing Developer
  • Sr. Member
  • *
  • Posts: 3028
  • Joomla & Virtuemart addon developper
    • Studio 42 - Virtuemart & Joomla extentions
  • VirtueMart Version: 2.6 &amp; 3.0.x.y
Re: XML FEED - if manufacturer
« Reply #1 on: June 04, 2018, 01:46:05 am »
Code: [Select]
if ($product->virtuemart_manufacturer_id = 1) {Means that you set $product->virtuemart_manufacturer_id  to value 1.
Comparing two values is == not =
Code: [Select]
if ($product->virtuemart_manufacturer_id == 1) {Is right

marvays

  • Jr. Member
  • **
  • Posts: 93
    • http://marvays.cz
  • Skype Name: marvays
Re: XML FEED - if manufacturer
« Reply #2 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"

marvays

  • Jr. Member
  • **
  • Posts: 93
    • http://marvays.cz
  • Skype Name: marvays
Re: XML FEED - if manufacturer
« Reply #3 on: June 04, 2018, 07:11:42 am »
Code: [Select]
if ($product->virtuemart_manufacturer_id = 1) {Means that you set $product->virtuemart_manufacturer_id  to value 1.
Comparing two values is == not =
Code: [Select]
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

Studio 42

  • Contributing Developer
  • Sr. Member
  • *
  • Posts: 3028
  • Joomla & Virtuemart addon developper
    • Studio 42 - Virtuemart & Joomla extentions
  • VirtueMart Version: 2.6 &amp; 3.0.x.y
Re: XML FEED - if manufacturer
« Reply #4 on: June 04, 2018, 11:43:37 am »
What is the ID of this manufacturer ?

marvays

  • Jr. Member
  • **
  • Posts: 93
    • http://marvays.cz
  • Skype Name: marvays
Re: XML FEED - if manufacturer
« Reply #5 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 . . . .

Studio 42

  • Contributing Developer
  • Sr. Member
  • *
  • Posts: 3028
  • Joomla & Virtuemart addon developper
    • Studio 42 - Virtuemart & Joomla extentions
  • VirtueMart Version: 2.6 &amp; 3.0.x.y
Re: XML FEED - if manufacturer
« Reply #6 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 ?

Ghost

  • Jr. Member
  • **
  • Posts: 408
Re: XML FEED - if manufacturer
« Reply #7 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:
Code: [Select]
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:
Code: [Select]
if ($product->virtuemart_manufacturer_id[0] == 1)

marvays

  • Jr. Member
  • **
  • Posts: 93
    • http://marvays.cz
  • Skype Name: marvays
Re: XML FEED - if manufacturer
« Reply #8 on: June 05, 2018, 09:46:26 am »
work for me this:
Code: [Select]
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 :(

Studio 42

  • Contributing Developer
  • Sr. Member
  • *
  • Posts: 3028
  • Joomla & Virtuemart addon developper
    • Studio 42 - Virtuemart & Joomla extentions
  • VirtueMart Version: 2.6 &amp; 3.0.x.y
Re: XML FEED - if manufacturer
« Reply #9 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