<?php require_once '../../app/Mage.php'; Mage::app()->setCurrentStore(Mage_Core_Model_App::ADMIN_STORE_ID); $collection = Mage::getModel('catalog/product')->getCollection()->addAttributeToFilter('type_id', 'configurable')->addAttributeToFilter('entity_id', array('gt' => 26360)); foreach ($collection as $product) { Mage::log($product->getId()); $product2 = Mage::getModel('catalog/product')->setStoreId(2)->load($product->getId()); $category = getLastCategory($product2); $nome_sottocategoria = $category->getName(); $nome_brand = $product2->getAttributeText("ca_brand"); $sku = $product2->getSku(); if ($product2->getTypeId() == "configurable") { $nome = ucfirst(strtolower($nome_sottocategoria . " " . $nome_brand)); $url_key = $nome_sottocategoria . "-" . $nome_brand . "-" . $sku; } else { if ($product2->getTypeId() == "simple") { $misura = $product2->getAttributeText("ca_misura"); $nome = ucfirst(strtolower($nome_sottocategoria . " " . $nome_brand . " " . $misura)); $url_key = $nome_sottocategoria . "-" . $nome_brand . "-" . $sku; } } $product2->setUrlKey($url_key); $product2->setName($nome); $product2->save(); } Mage::log("FINE"); function getLastCategory($product) { $categoryModel = Mage::getModel('catalog/category')->setStoreId(2); //Get Array of Category Id's with Last as First (Reversed)
break; } } if ($nome_coloreEng == "Mixed colours") { $nome_coloreEng = $productEng->getData("ca_codice_colore_fornitore"); } $entityType = Mage::getModel('eav/config')->getEntityType('catalog_product'); $attributeModel = Mage::getModel('eav/entity_attribute')->loadByCode($entityType, "ca_stagione"); $_collection = Mage::getResourceModel('eav/entity_attribute_option_collection')->setAttributeFilter($attributeModel->getId())->setStoreFilter(2)->load(); foreach ($_collection->toOptionArray() as $option) { if ($option['value'] == $id_stagioneEng) { $nome_stagioneEng = $option['label']; break; } } $category = getLastCategory($productEng); $nome_sottocategoriaEng = $category->getName(); $parent = $category->getParentId(); while ($parent != "2") { $id_categoria = $parent; $category = Mage::getModel('catalog/category')->setStoreId(2)->load($parent); $parent = $category->getParentId(); } $category = Mage::getModel('catalog/category')->setStoreId(2)->load($id_categoria); $nome_categoriaEng = $category->getName(); $stringa = "Shop"; $titleEng = ucwords(strtolower($nome_categoriaEng)) . " " . ucwords(strtolower($nome_brandEng)) . " " . ucwords(strtolower($nome_sottocategoriaEng)) . " " . ucwords(strtolower($nome_coloreEng)); $descriptionEng = $stringa . " online on coltortiboutique.com: " . ucwords(strtolower($nome_categoriaEng)) . " " . ucwords(strtolower($nome_brandEng)) . " " . strtolower($nome_sottocategoriaEng) . " " . strtolower($nome_coloreEng) . " of " . strtolower($nome_stagioneEng) . ". Guaranteed express delivery and returns"; $keyword1 = $titleEng; $keyword2 = ucwords(strtolower($nome_categoriaEng)) . " " . ucwords(strtolower($nome_brandEng)) . " " . ucwords(strtolower($nome_sottocategoriaEng)); $keyword3 = "Shop online " . ucwords(strtolower($nome_categoriaEng)) . " " . ucwords(strtolower($nome_brandEng)) . " " . ucwords(strtolower($nome_sottocategoriaEng));