How do I get Magento to always give the /catalog/product/view/id/ style url for products? - magento

I want Magento to always generate product urls in the format:
www.example.com/catalog/product/view/id/123/s/product-name.html
instead of the rewritten
www.example.com/product-name.html
The reason for this is mainly so that I don't have to worry if something happens to all my rewrites, or so I can feel free to truncate and rebuild core_url_rewrite if something goes wrong and it gets too big.
I don't want to stop using rewritten urls entirely. I like them for categories. I have fewer categories, and I very rarely change the names. I hate feeling like I can't change the name of a product because it will make the core_url_rewrite table grow and mess up any backlinks I've generated if I lose my rewrites. Also, I still want my current urls to work for as long as possible along with the /product/view/id urls.
Is there an easy way to do this without rewriting methods that I'm missing?
Or do I have to override some getProductUrl method? It looks like the answer lies in the getProductUrl() method in Mage_Catalog_Model_Product? That class seems to use the getProductUrl() method in Mage_Catalog_Model_Product_Url.
But again, if there's some simple configuration setting that would do the trick, I'd rather do that.

Magento handled it by own. Please follow the below steps.
1.Login to the admin panel
2. Then System >> Configuration >> Catalog >> Catalog >> Search Engine Optimization
3. Then Change the settings as per your requirement
4. As per your current requirement "Use Categories Path for Product URLs" will be YES
5. Then try to reindex full Via SSH.
Hope it will works.
Thanks

Related

"match-not-found" on products url rewrite

I'm trying to fix a few product's URLs and I've been doing the following process:
I run this on the database: delete from core_url_rewrite;
On the CMS I go to system > index management > GATALOG URL REWRITES and ask to rewrite it;
And then when I go on the CMS to Catalog > Url Rewrite Management and search for the products, on the column Request Path I get a lot of match-not-found-XXX , where XXX are different numbers.
It is happening with many products and I've done and redone the process above and still getting the same resuls.
I can't figure why it is happening. Any clue?
Magento usually adds the number 'XXX' to the url-path if another product already has the same path. Is there any chance that you imported those products and something gone wrong there?
Check the urk_key values for all those products and see what they are set too.
That's about the best clue I have right now, good luck!

A/B (Split) testing the shopping cart in Magento

We would like to implement A/B (or split) testing on our shopping cart in Magento.
The new design is enough of a departure from the existing one, that we cannot easily create the test using something like Visual Web Optimizer. The only way we would be able to do something with VWO is to create two different URLs for the cart, displaying the original one in the normal /checkout/cart and the new one in /checkout/shoppingcart - or something like that.
Is it possible to do something like this within Magento or am I going to delve deeper into the code?
One possible solution I was looking at was (doing a really dodgy hack) copying the CartController.php and creating a new controller called ShoppingcartController.php. I'm not a fan of this, it's just way to dodgy...but as it's going to be throw away code, I think I'd be able to sleep at night ;)
I'm completely lost as how I could do this. Ultimately, it would be great if I could create two front routes, pointing back to the same controller...but I don't think Magento is that flexible.
One way to accomplish this, is to create two "views" (under one website), and use different URL's for each view, such as: www.site.com www1.site.com.
Once this is set up have Google's A/B testing functionality (or some other JS) direct users to the different views.
Good luck!

codeigniter extra url segments

I am making a site for a client and decided i would use code igniter.
The site essentially has two backends, one for designers, and one for a sales team. So after logging in, the user will be redirected to either
mysite.com/sales/
mysite.com/design/
The sales team for example can view orders, containers, products, therefore i need a controller for each of these.
mysite.com/sales/orders/
The sales need to be able to view, edit, delete certain orders...
mysite.com/sales/orders/vieworder/235433
Basically my problem is i dont have enough url segments to play with.
My thoughts on solving my problem
removing the orders, containers, products classes and making ALL of their methods as methods of the sales class, although this would mean a large number of methods and loading all models so it seemed kind of pointless.
removing the sales/designer classes and controlling what each kind of user has access to based on a user type stored in session data.
a way of having an extra url segment?
I appreciate any advice, I just dont want to get 3 weeks into the project and realise i started wrong from the beginning!
Use folders.
If you make a subfolder in /application/ called sales you can put different controllers in there:
/application/
/sales/
orders.php /* Controller */
/design/
Then in orders.php you will put your vieworders($id) method and so on, and you will be able to acces it with domain.com/sales/orders/vieworders/id.
You can also make subfolders in the /models/ and /views/ to organize your files.
Now, Access Control is something apart and it depends more in the auth system you are using.
Give the user/designer a privilege, a column in the user table for example, check the permission of the user at the beginning of the function, then prevent or execute it.
This would be the exact way i would do it.
Seems like you should have a look into the routing class. Might be a dirty solution but rerouting the sales/(:any) to something like sales_$1 would mean you'd make controllers with names like sales_orders.
Same for the design part.
(FYI: $routing['sales/(:any)'] = 'sales_$1'; should do the trick; see application/config/routing.php).

how to add more simple products into configurable products using magento API

How can I simply add new simple products incrementally to configurable products?
or do I still need to retrieve the 2 original arrays of the pre-defined configurable product (getConfigurableAttributesData and getConfigurableProductsData) first, append the new arrays and set them again? Is it worked for my case just as the first-time creation?
And if the new simple product owns a new attribute / attribute options, do I also need to create /edit the attribute first before adding?
Thanks in advance!
The API as it stands does not have the functionality to do this.
Your options are:
Extend the API. (Hours of fun)
Do it with Magento methods in your own module or standalone code that includes Mage.php.
SQL script mixed in with your existing API code.
Buy someone's module - (Hope your German is good)
The approach you take also depends on your SKU naming scheme, if you have a simple BASECODE-SIZE-COLOUR type of scheme then the SQL option can work a treat, and in next to no time, but will be heavily scorned on by Magento evangelists.
That means you are probably going to have to write your own code. Here is a very useful site that should help get you started:
http://www.ayasoftware.com/
As well as being able to import configurables (by a variety of means including SQL) there are also snippets of code useful for updating superattribute price differentials. No readymade complete solution, but, you may need to roll your own anyway depending on your SKU naming scheme.
Whilst you are at it you may also want to write some code to find simple products that are not hooked up to anything when they should be, i,e. the ones with no visibility.

Wordpress: How do I convert a generated URL (permalink) to a pretty URL?

In a plugin, I am generating a paginated link to a category,
i.e. http://localhost/?cat=17&paged=5. The category is known by slug and id.
Is there a way to have this URL converted to the user defined "nice permalink" format,
i.e. http://localhost/category/foo/page/5?
(Assuming we're running Wordpress 2.8/2.9+)
Edit: Since there are some misunderstandings about what I'm trying to achieve, here's what I have:
The category ID
The page number (i.e. the fifth page of that category's archive)
With these data I can create the URL to that page, which would be, for example, http://localhost/?cat=17&paged=5, and that works well. The problem is of a visual nature: If the user has pretty permalinks enabled, then this won't fit in very well.
Question is: How do I get the correct, pretty permalink (i.e. http://localhost/category/foo/page/5) from (or for) the information I have?
Edit 2: Obviously if a user has pretty permalinks disabled, then there are no pretty permalinks. I know that, and that is really not subject of the question ... For the moment, let's just assume the user has an arbitrary permalink setting. I generate a link, and it should look like the user wants it to.
Have you looked at the WP_Rewrite?
Does All In One SEO meet your requirements? I actually bought the "pro" version for like $30 USD and it was well worth it.
My Wordpress installation (2.9.2) does this automatically - canonical URLs have been built into Wordpress for some time. Maybe your plugin is disabling this feature?
I'm guessing you already figured it out but I just wanted to put this out for others. I think I understand your situation. If I've read your question correctly, changing admin permalink settings does not apply.
You can get the category ID then use get_category_link() function to get the 'pretty' permalink. Then append the pagination to the end.
You could explode the permalink to get the category ID and pagination number, then use the step above to put it together.
Is this what you were looking for?
The correct way to generate the link would be to use get_category_link and add_query_arg
In your example, the following would work:
$category_link = add_query_arg( array('paged' => 5), get_category_link($category->term_id));
This will generate the URL and Wordpress will redirect to the correct page.
check this page out, it explains pretty permalinks pretty good.
http://codex.wordpress.org/Using_Permalinks
You should find these settings in
Wordpress->Settings->Permalinks
I think
/%category%/%postname%
in the direction what you want
You can also try to redirect your url using htaccess, here are some examples:
[http://]perishablepress.com/press/2008/02/06/permalink-evolution-customize-and-optimize-your-dated-wordpress-permalinks/
Sorry darf bis jetzt nur ein link posten pfft... :-(
kind regards,
Mahatmanich

Resources