News:

You may pay someone to create your store, or you visit our seminar and become a professional yourself with the silver certification

Main Menu

product specification plugin

Started by emedina, August 05, 2015, 20:32:47 PM

Previous topic - Next topic

emedina

Why this plugin doesn't store anything in database?
I created a customfield plugin specification. when i assign to a product, two input boxes appear but data isn't store after saving.
How must we use it?

Thanks

Studio 42

hi emedina,
The specification plugin is so to say a test plugin, of course this have to be fixed.
Why you need it?

If you don't have to search by specification then use 2 "string" (or more) custom fields.
You can use a parent custom field to group it and add all in one time in product.

If you need search, you can find search filter (paid) plugins for virtuemart using "standard" customfields .

Greets,
Patrick

emedina

#2
Hi,

In vm 2.0.26 works fine, but in 3.0.9 doesn´t work.
I need to specificate several properties of a product under the same group. Customfields groups should be nice but, i think that have a very big mistake. In the database customfields groups look like this:
virtuemart_product_id     customfield_id     customfield_value     ordering
            5                                   3                              ''                  0       //this is the group
            5                                   4                          'value'             1
            5                                   5                   'other value'           2
            5                                   3                           ''                     3  //other group
            5                                   4                        'value b'            4
            5                                   5                        'value c'             5
            5                                   3                           ''                     3  //other group
            5                                   4                        'value d'            4
            5                                   5                        'value e'             5

With this esquema, we can't make 'self joins' in a sql select, cause the unique primary key is 'vituemart_product_id', so this sql statement: (trying to select 'value b')

'SELECT table2.customfield_value from #__vituemart_product_customfield as table1 LEFT JOIN #__virtuemart_product_customfields as table2 on (table1.virtuemart_product_id = table2.virtuemart_product_id) where table1.customfield_id=4 and table1.customfield_value='value' and table2.customfield_id=4

This will return two results 'value b' and 'value d'.

Virtuemart customfields group should have a parent_id to make them unique.

P.S. Sorry my poor english

Studio 42

Hi,

I don't know your project, but this is not a big issue, you can group by virtuemart_product_id in a query to remove duplicates.

Greets,
Patrick

i speak french and german if you prefer

emedina

Quote from: Studio 42 on August 06, 2015, 12:41:04 PM
Hi,

I don't know your project, but this is not a big issue, you can group by virtuemart_product_id in a query to remove duplicates.

Greets,
Patrick

i speak french and german if you prefer

The problem is not the duplicates. The problem is diferent values on the same product and same virtuemart_custom_id.
I think this plugin's problem is the even plgOnProductStore isn't triggering.

I speak spanish, sorry.

Studio 42

I don't get you?
If you have duplicate value, then you have added this or not ?
If you need product search result, then on using group by product id give only product with same id one time :
'SELECT table2.customfield_value from #__vituemart_product_customfield as table1 LEFT JOIN #__virtuemart_product_customfields as table2 on (table1.virtuemart_product_id = table2.virtuemart_product_id) where table1.customfield_id=4 and table1.customfield_value='value' and table2.customfield_id=4'
Why you need to do this ?

emedina

Quote from: Studio 42 on August 06, 2015, 14:37:21 PM
I don't get you?
If you have duplicate value, then you have added this or not ?
If you need product search result, then on using group by product id give only product with same id one time :
'SELECT table2.customfield_value from #__vituemart_product_customfield as table1 LEFT JOIN #__virtuemart_product_customfields as table2 on (table1.virtuemart_product_id = table2.virtuemart_product_id) where table1.customfield_id=4 and table1.customfield_value='value' and table2.customfield_id=4'
Why you need to do this ?

ok, i'll try to be more specific.

Imagine you have a batery for this mobile phones:

brand              model
samsung     galaxy s2
samsung           galaxy s3
samsung           galaxy s4
iphone                 s4
iphone                  s5
lg                            l9

you create a group called 'phone' whith id=1, a string (brand) with id=2 and a string (model) with id= 3, for a product with id 25. You table looks like
virtuemart_product_id       virtuemart_custom_id          customfield_value           ordering
25                                                     1                                         ''                             0
25                                                     2                                       'samsung'                 1
25                                                     3                                      'galaxy s2'                 2
25                                                     1                                         ''                             3
25                                                     2                                       'samsung'                 4
25                                                     3                                      'galaxy s3'                 5
25                                                     1                                         ''                             6
25                                                     2                                       'samsung'                 7
25                                                     3                                      'galaxy s3'                 8
25                                                     1                                         ''                             9
25                                                     2                                       'samsung'                 10
25                                                     3                                      'galaxy s4'                 11
25                                                     1                                         ''                             12
25                                                     2                                       'iphone'                     13
25                                                     3                                        's4'                           14
25                                                     1                                         ''                             15
25                                                     2                                       'iphone'                     16
25                                                     3                                        's5'                           17
25                                                     1                                         ''                             18
25                                                     2                                         'lg'                          19
25                                                     3                                        'l9'                           20

Now, you need to know for what samsung's model is compatible your battery. With this sql:
'SELECT table2.customfield_value from #__vituemart_product_customfield as table1 LEFT JOIN #__virtuemart_product_customfields as table2 on (table1.virtuemart_product_id = table2.virtuemart_product_id) where table1.customfield_id=2 and table1.customfield_value='samsung' and table2.customfield_id=3

Whith this joining you receive these values because all have the same primary key-> galaxy s2, galaxy s3, galaxy s4, s4,s5, l9.
if you groups by virtuemart_product_id only receive 'l9', the last result.



Studio 42

Please try this query:
SELECT pc1.`virtuemart_product_id`, pc1.`customfield_value` as value FROM `#_virtuemart_product_customfields` pc1
LEFT JOIN `#_virtuemart_product_customfields` pc2 on pc1.`virtuemart_product_id` = pc2.`virtuemart_product_id`
WHERE pc1.`customfield_value`='myvalue' AND pc1.virtuemart_custom_id=12
GROUP BY pc1.`virtuemart_product_id`

I don't know if this is what you mean, in other case you can use mysql group concat, to chekc only if you have results on left join.
I think your query is not right.

emedina

Quote from: Studio 42 on August 06, 2015, 21:55:41 PM
Please try this query:
SELECT pc1.`virtuemart_product_id`, pc1.`customfield_value` as value FROM `#_virtuemart_product_customfields` pc1
LEFT JOIN `#_virtuemart_product_customfields` pc2 on pc1.`virtuemart_product_id` = pc2.`virtuemart_product_id`
WHERE pc1.`customfield_value`='myvalue' AND pc1.virtuemart_custom_id=12
GROUP BY pc1.`virtuemart_product_id`

I don't know if this is what you mean, in other case you can use mysql group concat, to chekc only if you have results on left join.
I think your query is not right.

omg, it works like a charm!!! Only a little fix on your query: "SELECT pc1.`virtuemart_product_id`, pc2.`customfield_value` as value FROM `#_virtuemart_product_customfields`"

In other way, i spend a lot of time in plg_product_specification and i've found a fix:
In vm2, not vm3, plugin stores data but don't get data. In administrator/components/com_virtuemart/plugins/vmcustompluging.php find the function getPluginCustomData(). This functions have to if statements to check data, but the second if always returns false because at this point object key is defined but IT'S NULL:
            if (isset($this->params->$k) && $datas->$k == 0) { line 199 aprox
               continue;
               
            }
just remove it, coment it or replace like this-> if (!isset($this->params->$k) && $datas->$k == 0))

still ivestigating in vm3.

Studio 42, thank you very much!!!