News:

Looking for documentation? Take a look on our wiki

Main Menu

XML FEED - if manufacturer

Started by marvays, June 03, 2018, 22:17:38 PM

Previous topic - Next topic

marvays

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>
";
}

Studio 42

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

marvays

thx i will try it.
PS: How if ($product-> ???? i can use for "if" ? . . . . . i know only "price"

marvays

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

Studio 42

What is the ID of this manufacturer ?

marvays

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

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

#7
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)

marvays

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 :(

Studio 42

$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