Author Topic: Problem when importing product with discount to database  (Read 2882 times)

adam.sandor

  • Beginner
  • *
  • Posts: 6
Problem when importing product with discount to database
« on: September 07, 2010, 08:54:51 am »
I'm importing products directly into the database (not through the GUI). My problem is that discounts work very strangely. All the products I'm importing have different discounts so I'm creating a discount for each of them separately. What I do exactly is this:
1. create a record in product_discount table, set the following values:
   amount = how much I want to subtract from the price of the product
   is_percent = start_date = end_date = 0
2. set the product_discount_id column in the product table to the id of the new record in the product_discount table

The strange thing is that this sometimes works, and sometimes not. When it's not working then I see the following:
* On the webshop admin interface I see the discount correctly
* When I click on save the summary screen shows no discount
* In the webshop the discount isn't shown

This strange situation seems to be happening randomly. Sometimes no discount shows up, sometimes I see an old discount even after updating the old one. In the database everything seems to be in order (except if there is some other table I should be updating). It seems to me that this is some kind of caching problem, with some cache not being updated if not going through the GUI (but saving in the GUI doesn't help neither). To support this, I could swear that when I gave up yesterday, the webshop was in a state that out of my two products, the discount showed up only on one. But when I looked at it today both had their discounts set up properly...

Any ideas on how this could be fixed are welcome, it's the last step for my app to be finished and I have no clue what to do. Thank you!

zanardi

  • Contributing Developer
  • Full Member
  • *
  • Posts: 878
    • GiBiLogic
Re: Problem when importing product with discount to database
« Reply #1 on: September 07, 2010, 09:53:14 am »
If you see the right discount in backend, just wait for a while: Joomla cache and browser cache sometimes keep old data. I had the same problem: i applied a new discount, could not see it in the frontend, waited the next day and it was there all right.
--
Francesco (zanardi)
http://extensions.gibilogic.com
@gibilogic on Twitter

adam.sandor

  • Beginner
  • *
  • Posts: 6
Re: Problem when importing product with discount to database
« Reply #2 on: September 07, 2010, 09:58:22 am »
Thanks for the answer. Its good to know where the problem is, but I still need a solution, because my customer won't accept that his imports appear with such a long delay. Is there a way to disable this caching mechanism? I checked the Joomla cache in global config, but it says that the cache directory is unwritable, so I'm guessing that this kind of cache is effectively disabled.

franzpeter

  • 3rd party VirtueMart Developer
  • Jr. Member
  • *
  • Posts: 467
    • 2in1-online | Software, Mac, PC, Netzwerk, Drucker, Pad, Display
  • VirtueMart Version: Virtuemart 3.2.6
Re: Problem when importing product with discount to database
« Reply #3 on: September 07, 2010, 10:51:39 am »
Did you deactivate the cache in configuration -> system?
It could be a problem too that you create the date in a wrong format. do you try to insert something there or do you just insert nothing to call the standard value?

adam.sandor

  • Beginner
  • *
  • Posts: 6
Re: Problem when importing product with discount to database
« Reply #4 on: September 07, 2010, 11:38:31 am »
1. I have not set up the site, but the only cache setting I can find is in Global Configuration / Cache tab. There I can set the path for the cache and the timeout. And there a yellow warning triangle informing me that the cache directory is unwritable, and I should fix this before turning on the cache. I don't see any place to turn the cache on or off in Joomla or Virtuemart settings.
2. I leave everything on default values except for the amount.

zanardi

  • Contributing Developer
  • Full Member
  • *
  • Posts: 878
    • GiBiLogic
Re: Problem when importing product with discount to database
« Reply #5 on: September 07, 2010, 14:27:56 pm »
First of all, let us know if this is indeed the case. Did you check if discounts appear correctly about a day after they have been changed? No sense in losing time on cache settings until we're sure they're really the cause of the issue.
--
Francesco (zanardi)
http://extensions.gibilogic.com
@gibilogic on Twitter

adam.sandor

  • Beginner
  • *
  • Posts: 6
Re: Problem when importing product with discount to database
« Reply #6 on: September 07, 2010, 20:03:35 pm »
Yes, it definetly seems to be the case. Discounts appear correctly after some time.

zanardi

  • Contributing Developer
  • Full Member
  • *
  • Posts: 878
    • GiBiLogic
Re: Problem when importing product with discount to database
« Reply #7 on: September 08, 2010, 10:42:40 am »
Ok, then, it is a cache issue: we will have a look at it. Which VM and Joomla version?
--
Francesco (zanardi)
http://extensions.gibilogic.com
@gibilogic on Twitter

adam.sandor

  • Beginner
  • *
  • Posts: 6
Re: Problem when importing product with discount to database
« Reply #8 on: September 08, 2010, 14:10:09 pm »
Well it seems that my customer is using ancient versions of both. Sorry I didn't check this earlier. Do you think that an upgrade would solve the problem?

PHP: 5.1.4
Joomla: 1.0.8 Stable [ Sunshade ] 26-Feb-2006 05:00 UTC
VM: VirtueMart 1.0.5 stable  [Built for Comfort] 07/05/2006 19:23 GMT

zanardi

  • Contributing Developer
  • Full Member
  • *
  • Posts: 878
    • GiBiLogic
Re: Problem when importing product with discount to database
« Reply #9 on: September 08, 2010, 16:39:22 pm »
Well, THAT is really ancient :-) Real problem here is, they're not supported anymore. Keep that in mind.

Now I have one bad piece of news and one good piece news.
The bad one is that an upgrade will not solve your issue.
The good one is that maybe i found a fix. Try to set the right Timezone in your Joomla site configuration (default is GMT but i think you're not GMT). I tested it a moment ago and that did the trick.

Technical specification: when you create a discount, it is created with a start date which is NOW. If your timezone is not configured correctly, NOW will start an hour in the future.
--
Francesco (zanardi)
http://extensions.gibilogic.com
@gibilogic on Twitter

adam.sandor

  • Beginner
  • *
  • Posts: 6
Re: Problem when importing product with discount to database
« Reply #10 on: September 08, 2010, 21:13:02 pm »
Thanks for the tip. Unfortunately my timezone is correctly set to GMT+1 (I'm in Slovakia), so this will not be the case.
You write that a new discount is created with start date NOW. When I create the discount both date values are 0. Could this be the problem?

tukun

  • Beginner
  • *
  • Posts: 13
Problem with Virtuemart installation
« Reply #11 on: September 09, 2010, 08:00:44 am »
Hi,

My PHP version is  4.4.8 so i m unable to install the latest version of virtuemart.
Is there any substitute way other than updating the PHP version of the server.

Please help

zanardi

  • Contributing Developer
  • Full Member
  • *
  • Posts: 878
    • GiBiLogic
Re: Problem when importing product with discount to database
« Reply #12 on: September 09, 2010, 11:07:03 am »
@adam.sandor: i am sorry i really thought this was a possible fix. In my case it did work. Try to understand how much time pass before discounts are shown. I still think this could be "datetime" related.

@tukun: please open a new thread when you have a new problem, don't reply to an existing one. No, there is no workaround: VM uses PHP5 functions and will simply not work with PHP4.
--
Francesco (zanardi)
http://extensions.gibilogic.com
@gibilogic on Twitter