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

Feature/use seo url key for url rewrites #132

Open
wants to merge 4 commits into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 18 additions & 2 deletions Product/Model/Factory/Import.php
Original file line number Diff line number Diff line change
Expand Up @@ -169,7 +169,23 @@ public function addRequiredData()

if (!$connection->tableColumnExists($tmpTable, 'url_key')) {
$connection->addColumn($tmpTable, 'url_key', 'varchar(255) NOT NULL DEFAULT ""');
$connection->update($tmpTable, array('url_key' => new Expr('LOWER(`sku`)')));

// Use seo url key as for rewrite url if specified - use sku otherwise
$langStores = $this->_helperConfig->getStores(array('lang'));

$seoField = '';
foreach ($langStores as $suffix => $store) {
if ($connection->tableColumnExists($tmpTable, 'seo_url_key-' . $suffix)) {
$seoField = 'seo_url_key-' . $suffix;
break;
}
}

if (empty($seoField)) {
$connection->update($tmpTable, array('url_key' => new Expr('LOWER(`sku`)')));
} else {
$connection->update($tmpTable, array('url_key' => new Expr("IF(LENGTH(`$seoField`) > 0, `$seoField`, LOWER(`sku`))")));
}
}

if ($connection->tableColumnExists($tmpTable, 'enabled')) {
Expand Down Expand Up @@ -929,7 +945,7 @@ public function setUrlRewrite()
);
}
}

foreach ($affected as $store) {

if ($store['store_id'] == 0) {
Expand Down