Latest News: (loading..)
Sign in to follow this  
Followers 0
bruyndoncx

Firefox conQuery: osC Edit Product

15 posts in this topic

I've recently started using Firefox in order to be able to customize my browser more easily. Basically I want to go straight into the admin for editing the items/page I'm looking at from the catalog side.

 

The example below uses the ConQuery Firefox extension in order to add a menu item to rightclick menu.

ConQuery allows you to take pieces from your current webpage and pass this as parameter to another website/webservice. So it has defined interfaces to query google, yahoo, ebay etc There is an online repository with samples.

 

Installation is easy in 3 steps:

1. Install ConQuery extension

2. Restart firefox

3. Save embedded file as osCeditProduct.cqr in the searchplugins directory under your firefox installation

Now you can further customize the options, but you should already be seeing the oscommerce option under the Conquery menu.

 

It works well as it opens the page with the passed parameters but there is a glitch.

It is only supposed to show up in the menu when 'products_id' is part of the url string, but it is showing up all the time.

I suspect my regex is not correct, but I'm not sure.

 

Are there any firefox enthousiasts and regex experts outhere that can help ?

If this is solved, I can create some more variants for categories, specials, attributes etc, it's just that I want to avoid cluttering up my menu too much with irrelevant options ...

 

# Mozilla/osCommerce plug-in by Carine Bruyndoncx (info@calimeross.com)
# osCommerce Edit Product

<search 
  name="osC edit Product"
  description="Edit current product"
  method="GET"
  action="http://[:host]/admin/categories.php"
  category="osCommerce"
  showiftarget="[:url]"
  showif="products_id=(\d+)"
  queryEncoding="utf-8"
  queryCharset="utf-8"
>
<input name="pID" value="[:matched:1]">
<input name="action" value="new_product">

</search>

Share this post


Link to post
Share on other sites

I tried using this and I get errors...

 

Warning: reset(): Passed variable is not an array or object in /tosite/admin/includes/classes/object_info.php on line 17

 

Warning: Variable passed to each() is not an array or object in /tosite/admin/includes/classes/object_info.php on line 18

 

It does open the page but there is no information in any of the fields. Would be really cool if this worked though, thanks for trying to make our lives easier!

Share this post


Link to post
Share on other sites

Well this is the error you get on pages that don't have 'products_id=XX' in the URL, thus the reason to only show it in the menu when it would actually be working ...

 

Any takers ?

Share this post


Link to post
Share on other sites

I am not real smart but I am going to guess that means it should only work when you are on an actual products page?

 

If that is so, then I still get the error. Maybe it is because of the cname pname thing?

Share this post


Link to post
Share on other sites

yes, that is it in your case.

If you use the SEO contribution, the page url doesn't have the products_id, but the pname parameter.

I'm not 100% familiar with this, but I guess if pname is truely uniquely identifyiing a product in your store, a similar conquery could be made to work in your case too ... [ chemo where are you ]

Edited by bruyndoncx

Share this post


Link to post
Share on other sites

Ok, that makes lots of sense. I am sure you or someone else will figure it all out... again, thank you for helping others! =)

Share this post


Link to post
Share on other sites
yes, that is it in your case.

If you use the SEO contribution, the page url doesn't have the products_id, but the pname parameter.

I'm not 100% familiar with this, but I guess if pname is truely uniquely identifyiing a product in your store, a similar conquery could be made to work in your case too ... [ chemo where are you ]

I don't know what falvor of regex the plugin uses (PERL5, PCRE, etc.) but you can probably use the normal numeric character class like this:

showif="products_id=([0-9]+)"

This format and character class is used among every regex flavor I've ever used.

 

With respect to the cName/UltimateSEO URLs: the conversion to the cooresponding products_id and cPath is done at the script level so the plugin would only work with normal parameter driven URLs.

 

Nice idea though Carine!

 

Bobby

Share this post


Link to post
Share on other sites

thanks chemo, I knew I could rely on you !

for pointing out the regular regex, I knew I wasn't using the most popular convention, but I was happy that it worked ...

 

but somehow, the conquery showif is not working for me yet ...

not sure if it is a bug in conquery. I guess as long as it is not correctly behaving based on the context, releasing this as a contribution is only gonna give more trouble.

 

In the meantime, feel free to use it asis (no warranty :D) and do let me know if you find out how to make it truely context sensitive, ie only showing on pages where there is a products_id in the url ...

Share this post


Link to post
Share on other sites

another regex question ... how do you extract the category id out of the cPath variable ?

 

eg cPath=46_63

 

what is the syntax to select the last number in the string following cPath where numbers are delimited by '_' (I don't want it to find a product_id later on in the string ...)

Share this post


Link to post
Share on other sites

Wow. This is a GREAT tool, particularly if you have a store with a lot of products and categories. I tuned up your code a litte bit, but I am still trying to figure out the showif part. Right now it shows up all the time, but it works like a charm. Here is the fixed code:

 

# Mozilla/osCommerce plug-in by Carine Bruyndoncx (info@calimeross.com)
# Tuned up by Brent Friar (bf@dougherbert.com)
# osCommerce Edit Product

<search
name="osC edit Product"
description="Edit current product"
method="GET"
action="http://[:host]/catalog/admin/categories.php"
category="osCommerce"
showiftarget="[:linkurl]"
showif="cPath=(.*)&products_id=([0-9]+)"
queryEncoding="utf-8"
queryCharset="utf-8"
>
<input name="cPath" value="[:matched:1]">
<input name="pID" value="[:matched:2]">
<input name="action" value="new_product">

</search>

This preserves the categories so you can edit product and keep it where it belongs. I'll let you know if I figure out the showif deal.

Edited by NHRAFan

Share this post


Link to post
Share on other sites

When in doubt, read the directions. The showif parameter is only used to get the regex for the output of the plugin, the plugin will ALWAYS show, even if there are no matches in the selection. That is unless you set it to only show when there is a match.

 

Right click to bring up the context menu, then double click on "Query to...". This will bring up the properties for the plugin. Find the osC edit Product selection in the list and make sure that you click the checkbox under "Show?" OFF. Now you will only get the osC option when you get a regex match.

 

The downside is that you can't really use it if you have SEO URLs installed. In my case, I have SEO installed, but I have too many products for the products cache. I disabled the products cache, but I still have manufacturers and categories enabled. This means I get to use both ;)

 

This would be a handy too to edit your store with even if you have SEO URLs. All you need to do is disable the products cache when you want to do your editing.

 

Find this line in includes/seo_cache.php:

$cache->save_cache($cache_file . 'products', $prod_cache, 'EVAL', 1 , 1);

 

And replace it with:

$cache->save_cache($cache_file . 'products', $prod_cache, 'EVAL', 1 , 0);

 

Then simply reset the cache through your admin. Now your products will have standard links and work with your ConQuery plugin. When you are done editing, switch the code back and reset your cache again to fully enable SEO URLs again.

Edited by NHRAFan

Share this post


Link to post
Share on other sites

NHRAFAn, BigThanks !

I missed that completely, I assumed there would be a way to turn a query completely off, not even context sensitive - yup, should have read more carefully.

 

For the categories, I've tried different things, but it either worked only in the main, or only in the subcategory, maybe I just take the stupid route and create clones. With the showif working, there is always only one showing ... :D

Share this post


Link to post
Share on other sites

I was thinking about this last night because I would like to be able to do the same thing with categories and manufacturers, and I am pretty sure it can be done with SEO URL support. The idea would be to send the query to a NEW page that will parse out the -c-, -p-, and -m-, then send it to the appropriate page edit page in the admin. That would save all the trouble of turning off SEO URLs just to do editing. Not high on the priority list, but I'll take a look at a hack for this when I get a moment or 2.

Share this post


Link to post
Share on other sites

This is a great idea.

Since reading about this on the forums I have made several scripts that makes working with the shop alot faster. (I'm on dialup from time to time). No more reloads just to get the right product selected in the categories area. Just rightclick to edit product, or attributes, or add a new one.

 

I like it, plain and simple. :)

Try it.

 

Zipper

Share this post


Link to post
Share on other sites

I agree :D

BTW, nice signature !

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!


Register a new account

Sign in

Already have an account? Sign in here.


Sign In Now
Sign in to follow this  
Followers 0