2

Background: I have some upgrade scripts, which implement methods only supported by new Magento versions. Magento 1.4 lacks these methods.

Task: My task is to implement support of Magento 1.4 in these scripts.

Solution: Currently I see this as checking if Magento version is higher then something, use the existing method, if lower then something, use plain MySQL / some methods that exist in Magento 1.4 / Zend, that result in same.

Problem: It is hard to understand what plain MySQL corresponds to methods, which I need to implement.

Questions:

  • Is there a way to monitor the database for all scripts that get executed ?
  • Is there a manual for Magento 1.4 methods that can be used in upgrade scripts ?
  • Am I on the right path to solve this case ?
4
  • Is this for a custom module? Why are you worrying about Plain MySQL? Commented Nov 30, 2014 at 14:12
  • @brentwpeterson Methods used in the script currently are only supported by 1.6+, I'm installing this module on 1.4. Yes, a custom module Commented Nov 30, 2014 at 14:13
  • And you have tested a version that works in 1.4? Why don't you simple ask what version of Magento then execute the appropriate script? Commented Nov 30, 2014 at 14:14
  • There is no version of this module that works on 1.4. I'm rewriting the module to work on 1.4 :) So, the only thing that is not compatible are the upgrade scripts, which I am rewriting here. Commented Nov 30, 2014 at 14:16

1 Answer 1

3
  • Is there a way to monitor the database for all scripts that get executed ?

What I always do is add logging to my install/upgrade scripts. I place Mage::log() lines at crucial points in my scripts. I usually add prepend the message with info like the filename (basename(__FILE__)) and the directory name (= resource name, basename(dirname(__FILE__))). The message itself would contain info about the executed action and the result of the action (like the last inserted ID or a boolean return value of a method that was executed).

  • Is there a manual for Magento 1.4 methods that can be used in upgrade scripts ?

I would suggest that you set up a Magento 1.4 and a Magento 1.6+ and add the module to both. If I work with multiple setups then I usually deploy the module into both setups with symlinks (e.g. with Composer). So when I change something to the module, it will change on both setups.

If you use an IDE with code hinting and you define your $this or $installer variable through a PHPdoc var definition (like /** @var $installer Mage_Core_Model_Resource_Setup */) then you can easily find out what methods there are that you can call and by navigating to them you can see what they will do.

  • Am I on the right path to solve this case ?

I think you are and I hope we have helped you to get a bit closer to solving this.

3
  • You can also enable full sql logging in your mysql service. This will then log every sql thrown at the service. This is standard for me on a development box. I frequently tail that log file whilst busy with a debugger, using breakpoints. I can then step through my code, and monitor what SQL is thrown at the server as you step through the code. Commented Feb 18, 2015 at 9:01
  • @ProxiBlue, I sometimes use SQL logging to debug things and I get a huge amount of queries per page request. In this case I only need one line indicating if an install/upgrade script has ran. But you got a good point here. Commented Feb 18, 2015 at 9:05
  • Hence the use of the debugger, and breakpoints ;) - I can then control the code execution, and see the SQL that was run as I step over each line of code. Commented Feb 18, 2015 at 9:20

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.