Topic bump – another bugfix
|

|
|
|||
|
Club Member
![]() ![]() ![]() Messages :
Joined: 2009-06-09 |
Topic bump – another bugfix |
|
|
|
|
|
|||
|
V.I.P.
![]() ![]() ![]() ![]() Messages :
Joined: 2008-08-03 |
Hmm I don’t use or have a windows server to test this on, so I have to trust you there and it does indeed make sense – since microsoft got the directory separators the wrong way around years back and stubbornly won’t change them
It should have worked for both. What the code does is REMOVE the extra bits that 1.2 adds – if they are there – so that the result is the same from both, then adds it back in again (or adds it in the first place in the case of 1.1). It worked fine here on a unix 1.1 install, and I’ve now got a 1.2 install too, so i’ll test on that also to make sure I got the logic correct. In theory the line:
$product_link = str_replace('http://'.$_SERVER['HTTP_HOST'].__PS_BASE_URI__,'',$product_link);
will only affect 1.2, as the expression we’re searching for won’t be in the 1.1 function call result.
Wasn’t aware that this would make any difference, but sure it makes sense.
Yup. I’ve never used that feature, so didn’t even think to test for it – well spotted
This last one is a strange one – and may have been the result of your previous edits? In the code it’s an html entity (i.e. & gt;) – at least that’s what’s I see in dreamweaver code view on the original line 75! That is what google recommend. If your source file has anything other than that in it, then try changing it back in a plain text editor maybe? I’m not sure how lenient Google will be with just escaping it. I’ll do some testing on a local XP machine and try and work out how to handle the path differences between the two. Keep ‘em coming note: I’ll also add the option to select either the long or short product description I think in the next revision as this has been mentioned before (some folks only use the long description field so their feed descriptions are blank). Paul |
|
|
|
|
|
|||
|
Club Member
![]() ![]() ![]() Messages :
Joined: 2009-06-09 |
Hi Paul, Great. so:
For example, this is one line from my output xml
<g:product_type><![CDATA[Seasonal > Fall & Thanksgiving]]></g:product_type>
Your original code, produced this:
<g:product_type>Seasonal & gt; Fall & Thanksgiving</g:product_type>
(without the space, presta forum does conversion) which was rejected by google. I will report back about #1 and #2 soon. EDIT: |
|
|
|
|
|
|||
|
V.I.P.
![]() ![]() ![]() ![]() Messages :
Joined: 2008-08-03 |
I think the first two items are probably related. It works fine here on my unix boxes, so again I think it may be down to the different filesystems. I’ve got XAMPP set up, so I’ll do a quick 1.1 install and try it. I’ll also test on 1.2 unix – I suspect that this should be sufficient. The “missing” separators in the directory is a display issue I think, since the “/” is an escape character in the html world. That should be easy to fix – will just have to double them up, then fix them in the config variable again after the form returns. I understand what you mean about the categories – I’ve changed the getPath() member function to convert to html entities for each segment as they’re added together, which avoids the CDATA (you don’t want to use it unless you have to). btw send me a PM with your preferred url and i’ll add a credit on my site when the module is next uploaded |
|
|
|
|
|
|||
|
Club Member
![]() ![]() ![]() Messages :
Joined: 2009-06-09 |
Thanks Paul, I am struggling here with the backslash windows path – since there are so many calls to googlebase_filepath from the config. Also, note that you have a private $_filename that seems to be unused. So if you already have XAMPP, I will stop my attepmts, you know this code much better than me. About CDATA or not in product type – the reason I picked the CDATA route is because you are using recursion there, so if you are using some encoding anywhere other than the final return value, you get double escaping. I guess you can easily replace the CDATA (at the current location I placed it) with htmlspecialchars, and still leave the separator unescaped, as I have. And you are probably right about the product link related to windows path, makes total sense. |
|
|
|
|
|
|||
|
V.I.P.
![]() ![]() ![]() ![]() Messages :
Joined: 2008-08-03 |
I’ve just made the changes to the getPath() function so that as each catagory gets added it first has the numbers removed, then gets wrapped in an html_entities() function call. So it will only be done once for each element in the path. I would like to try and keep that loop as free from clutter as possible so that it doesn’t get completely out of control once more stuff gets added in there. I also think it makes it easier to see what’s going on, by having all the code related to generting the final output in the one place. I’ll have a look at what to do about the windows paths next |
|
|
|
|
|
|||
|
V.I.P.
![]() ![]() ![]() ![]() Messages :
Joined: 2008-08-03 |
Another revision, although I haven’t fixed the windows file system issue yet I have corrected some logic in the path generation in general as I spotted a major bug while testing on 1.2…. Updates: 1. private member function defaultOutputFile() added to handle getting the default location (bug fix and for future MS-Win compatibility) also fixes bug in original code to generate the default output file/path 2. private member function can_write() modified to allow passing of a filename. and PHP errors suppressed internally to it. 3. private member function getPath() modified to output valid xml 4. Removed 3rd party xml_convert code/licence again – unnecessary compatibility layer 5. Moved POST variable cleaning out of getContent() and into _postValidation() and cleaned up validation logic 6. Added the trailing slash in the <link> tag 7. Uninstall removes configuration variables Paul File Attachments
|
|
|
|
|
|
|||
|
V.I.P.
![]() ![]() ![]() ![]() Messages :
Joined: 2008-08-03 |
Just a thought for those who have been trying these versions as we go along. As of 0.6.2 clicking uninstall will remove the old configuration values and let you install the module again “fresh”. It is probably a good idea to do an install->uninstall->install loop just to make sure you’re starting from scratch again Paul |
|
|
|
|
|
|||
|
Club Member
![]() ![]() ![]() Messages :
Joined: 2009-06-09 |
Sounds and looks great. |
|
|
|
|
|
|||
|
V.I.P.
![]() ![]() ![]() ![]() Messages :
Joined: 2008-08-03 |
For this version, yes that seems to be the only outstanding issue. I’ve tested this version with two unix based sites running 1.1.0.5 and 1.2.0.5(beta 3) and all seems to work fine there. That’s not to say that differences in hosting environments might come into play introducing yet more “undocumented features” Paul |
|
|
|
|
|
|||
|
Club Member
![]() ![]() ![]() Messages :
Joined: 2009-06-09 |
Paul, There is still a problem with the product_link on 1.1. The reason is this:
$product_link = $link->getProductLink($Product['id_product'], $Product['link_rewrite']);
This line comes back with PS_BASE_URI but without domain. So the line following it:
$product_link = str_replace('http://'.$_SERVER['HTTP_HOST'].__PS_BASE_URI__,'',$product_link);
Does not clean it, since there is no match. Then, the following line:
$product_link = 'http://'.str_replace('//','/',$domain.$psdir.$product_link); // Do some extra cleaning to compensate for differences in PS versions
Creates an invalid link – it has both $psdir and PS_BASE_URI – as a part of $product_link So, I think this below code will work for both 1.1 and 1.2
$product_link = $link->getProductLink($Product['id_product'], $Product['link_rewrite']);The only change is that if statement, to add the domain if not there. Also, your categories are not htmlescaped properly – I still get ampersands and sort prefix. I propose to do the sort prefix removal and the html entities only once, at the end of the recursion (at this same line) + replace your gt; separator with the actual > sign – this way it seems to be working as expected. I am attaching the php modified with the above mentioned changes. If you dont like the attached solution, then in order to test you should create two categories with ampersand: File Attachments
|
|
|
|
|
|
|||
|
Club Member
![]() ![]() ![]() Messages :
Joined: 2009-06-28 |
Hi – What would cause this error: I get it two times when creating a feed file in 6.2. (also got it in the previous version. Is it caused by characters in my items? Are there some characters you canot use in your descriptions? etc Thanks |
|
|
|
|
|
|||
|
V.I.P.
![]() ![]() ![]() ![]() Messages :
Joined: 2008-08-03 |
@diamond204 : It looks to me like you have products with no image or maybe the “cover” image isn’t set? I would need to look into it more closely. I’ll note down that maybe I should test whether a product has any images, as it would certainly not work as expected in that instance. @Icarus. Sorry, I’ve realised that my testing methodology isn’t catching these variations properly – I have all my sites installed in the root dir for a start, so I’d made an assumption about the return value from the getProductLink() function that was just plain wrong I will also look at what I’ve done wrong in the category function using the setup you’ve suggested. A thought did strike me that the current method won’t work if someone decides to have a category named, for example “Themes for PrestaShop 1.2”. I’ll maybe try and check whether the sorting option is enabled, and if it is specifically remove the prefix only, rather than doing a replace. Paul |
|
|
|
|
|
|||
|
Club Member
![]() ![]() ![]() Messages :
Joined: 2009-06-09 |
Sure thing Paul. If you want me to test versions before you release, we can also do that, maybe not to bother everybody with the debugging process… |
|
|
|
|
|
|||
|
V.I.P.
![]() ![]() ![]() ![]() Messages :
Joined: 2008-08-03 |
Right, yet another new version. This one should address: - correct file paths etc. on windows machines – possibly… – yet another fix for generating the product type (please say I’ve nailed it this time!!!) – yet another fix for the product urls (ditto to above!) – A test for at least one image, else the tag is omitted Outstanding features/bugfixes: - just noticed that for 1.2 the price is being output at 6 decimal places instead of two. – need an option to select the long or short product description to be used in the feed. Paul EDIT: made a fix in the archive and re-uploaded : line 93 the pipe should, of course be a > now and not the html entity. File Attachments
|
|
|
|
|