Quote:
Originally Posted by totaltec
Phil,
I think I have found the class you would need to decorate. Take a look at classes/XLite/Core/Converter.php function buildCleanURL
This line in particular: $urlParams[] = $product->getCleanURL() . '.html';
Try changing that to a / instead of .html
Of course, don't modify the core file, decorate it in your module.
|
I made an attempt at your suggestion, but I'm very new to xcart 5, and not sure if I did this correctly. Below is an example of my Converter.php file. I added this and redeployed the store. I don't see any problems, but it doesn't appear to have changed the clean url. Can you take a look at my code below, and see what you think?
<?php
namespace XLite\Module\Pmall\PmallSkin\Core;
abstract class Converter extends \XLite\Core\Converter implements \XLite\Base\IDecorator
public static function buildCleanURL($target = '', $action = '', array $params = array())
{
$result = null;
$urlParams = array();
if ('product' === $target && empty($action) && !empty($params['product_id'])) {
$product = \XLite\Core\Database::getRepo('\XLite\Model\Produc t')->find($params['product_id']);
if (isset($product) && $product->getCleanURL()) {
$urlParams[] = $product->getCleanURL() . '/';
unset($params['product_id']);
}
}
if (
('category' === $target || ('product' === $target && !empty($urlParams)))
&& empty($action)
&& !empty($params['category_id'])
) {
$category = \XLite\Core\Database::getRepo('\XLite\Model\Catego ry')->find($params['category_id']);
if (isset($category) && $category->getCleanURL()) {
foreach (array_reverse($category->getPath()) as $node) {
if ($node->getCleanURL()) {
$urlParams[] = $node->getCleanURL();
}
}
}
if (!empty($urlParams)) {
unset($params['category_id']);
}
}
static::buildCleanURLHook($target, $action, $params, $urlParams);
if (!empty($urlParams)) {
unset($params['target']);
$result = implode('/', array_reverse($urlParams));
if (!empty($params)) {
$result .= '?' . http_build_query($params);
}
}
return $result;
}