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

One customfield, several products in vm3

Started by emedina, January 24, 2017, 13:10:31 PM

Previous topic - Next topic

emedina

Hi everybody.

A small introduction. Imagine you have a t-shirt store. You need Size customfield, maybe color one. In your store you have 1000 products, so in your virtuemart_product_customfields table you have 6000 entries. That's a lot.

In virtuemart 2 I found a trick. I only asigned size and colour in one product. Then copy the customfields template html output and paste in the whole template. In helpers/cart.php i commented:
// $product -> customfieldsCart = empty($tmpProduct -> customfieldsCart)? array(): $tmpProduct -> customfieldsCart;
With this little hack, all products in cart had the size and colour customfields.

Now in vm3 is more dificult. In helpers/cart.php the function "add" check customfields with this line:
$product->customfields = $customFieldsModel->getCustomEmbeddedProductCustomFields($product->allIds,0,1);

Ok, i've developed a plugin that extends virtuemartCart and links a custom vmprices.js in the frontend. When i debug the cart, the products have "fake" customfields (ok, that's good), but are not showing in the cart, neither in orders because product customfields are checked more times with the function getCustomEmbeddedProductCustomFields.


Is there anyway to make this work again without hacking the core? Maybe a pluggin that modify the product in the cart and in the order?

Thanks a lot.

Milbo

Should I fix your bug, please support the VirtueMart project and become a member
______________________________________
Extensions approved by the core team: http://extensions.virtuemart.net/

emedina

#2
That is a very good solution, but i've customers who are accustomed to create products without specifing product's parent.
I'm wondering what would happen if i create a product with all the customfields and then override all products in template like this $this->product->product_parent_id=$the_fake_one.

I think the template isn't the best place to do this. Maybe in a plugin, but, is there any list with all the plugins triggers?

P.S. GREAT job team!!

Milbo

I do not understand, why you cannot use the pattern, you should play a bit with it.
Should I fix your bug, please support the VirtueMart project and become a member
______________________________________
Extensions approved by the core team: http://extensions.virtuemart.net/