Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Vafsitemap bug #76

Open
echo1989 opened this issue Oct 30, 2014 · 6 comments
Open

Vafsitemap bug #76

echo1989 opened this issue Oct 30, 2014 · 6 comments

Comments

@echo1989
Copy link

Hi, Vafsitemap don't work. After i selected the vehicle, the products page don't work. I attempt to fix it myself for an hour but is very difficult for me. The error is 404 not found. Have any suggestion? The version is 3.0.2 on magento 1.8.1.

Thanks in advance.
Ivan

@echo1989
Copy link
Author

Please help me, in the folder of the controllers there isn't any file called ProductsController, so for this magento throw 404 error. Can you check please? I need of your help for this. Thanks in advance.

@monark88
Copy link

I can confirm this. Simliar problem with Magento 1.9.
There are ProductControllers, app/code/local/Elite/Vafsitemap/controllers/ProductController.php
so this could not be the problem...
I believe it's coming from a problem with URL rewriting..

@kylecannon
Copy link
Member

Unfortunately Magento completely changed their url rewrite system which broke vehiclefits on magento >= 1.8 I have unfortunately been unable to contribute at this time due to changing events. @joshribakoff is also in the same position as well.

@markshust
Copy link

There is actually a fairly simple solution to this (after banging my head against the wall for a while). Listen to event controller_front_init_routers and create a new observer for it.

Then in that custom observer: (I tweaked this to get working as desired)

<?php
class CustomExtension_Vafsitemap_Model_Observer_Url_Rewrite
    extends Elite_Vafsitemap_Model_Url_Rewrite
{
    public function controllerFrontInitRouters($observer)
    {
        $event = $observer->getEvent();
        $request = $event->getFront()->getRequest();

        $this->request = $request;
        $this->uri = $request->getRequestUri();

        if ($this->isProductListingRequest()) {
            return $this->rewriteProductListing();
        }

        if ($this->isVehicleProductRequest()) {
            $this->rewriteVehicleProductRequest();
        }
    }

    function rewriteVehicleProductRequest()
    {
        preg_match('#/fit/([^/]*)/(.*)#', $this->uri, $matches);
        if (!isset($matches[1])) {
            return false;
        }
        $vehicleSlug = $matches[1];
        $productSlug = $matches[2];
        $vehicle = $this->slugToVehicle($vehicleSlug);
        if (!$vehicle) {
            return false;
        }
        $this->rewriteTo("/$productSlug", $vehicle);
    }

    function rewriteTo($pathInfo, $vehicle)
    {
        $this->request->setPathInfo($pathInfo);
        $this->request->setRequestUri($pathInfo);
        $this->request->setParams($vehicle->toValueArray());
    }
}

This basically creates a custom router for the matching URL's.

@lawrencea1021
Copy link

@markoshust
Can you help me a little more. I am new to magento and not sure what to do from here. I really need this to work. Im not sure where else to look anymore.

@markshust
Copy link

sorry, can't help too much more. here's how to create event observers https://www.ashsmith.io/2012/12/making-use-of-observers-in-magento/

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

5 participants