Designbest Core Sviluppo
Goal
Realizzare una versione agile e super performante di Designbest usando le ultime tecnologie Microsoft disponibili (.NET Core 6 .NET Core 7).
Page Speed Insights
- Riduzione del TTFB (Time To The First Byte)
- Immagini di dimensioni adeguate al dispositivo (Imagekit.io)
- Specificare width e height per ogni immagine
- Specificare alt per ogni immagine
- Minificazione delle dipendenze da terze parti (animazioni fatte in linguaggio nativo piuttosto che utilizzo di plugin esterni)
- Raggruppamento (bundling) delle risorse CSS e Javascript
- Minificazione delle risorse raggruppate
- Ottimizzazione del tempo di Javascript (tramite promise e processi async).
- Inclusione delle risorse Javascript strettamente necessarie alla pagina (e non librerie complete)
- Inclusione delle risorse CSS strettamente necessarie alla pagina.
- Precaricamento della Largest Contentful Paint per ogni pagina
- Immagini e iframe lazy (caricamento pigro)
- Riduzione elementi in pagina tramite caricamenti asincroni su richiesta (modali, librerie)
- Compressione dell'HTML generato
- Compressione delle risorse statiche
- manifest con info per creare un PWA
- Velocità media caricamento pagina costantemente < 3s
SEO
- Semantica della pagina (h1, h2, section, main content, aside content, header, footer, nav).
- Gestione di meta tag seo description, title
- Href Lang (link seo che indicano la stessa pagina in lingua differente)
- Logiche di redirect applicative (con listing vuoti => redirect al listing superiore, negozio chiuso => redirect a listing di quella città)
- Structured Data (validate da Google)
- Breadcrumbs
- Loghi (nome organizzazione e canali social)
- Snippet di prodotto
- Snippet di recensioni (stelline)
- Casella di ricerca
- Caroselli (lista di prodotti)
- Attività locali (negozi)
Lato Applicativo
- Riduzione del TTFB (Time To The First Byte) tramite controllo completo sulle query e le stored procedure
- Logiche di redirect applicative (con listing vuoti => redirect al listing superiore, negozio chiuso => redirect a listing di quella città)
- Gestione geolocalizzazione (database MaxMind aggiornato)
- Algoritmi di ordinamento prodotti
- Gestione Ad manager (DFP secondo logiche custom di targeting ambiente/zona/manu)
- Gestione logiche 4Dem (ultimo prodotto visto, data, spedizione flusso newsletter)
- Bottoni Sponsor che appaiono nell'ambiente preciso
Database
Accorpamento database:
- Designbest
- Trovaprodotti
Tabelle
- Language
- LocalizedProperty
- Category
- ManufacturerContractType
- Manufacturer
- Product
- ProductCulture
- ProductBargain
- ProductBargainCulture
- ProductProperty
- ProductPropertyValue
- Mapping_Category_ProductProperty
- Mapping_Product_ProductPropertyValue
- ShopPointProperty
- ShopPointPropertyValue
- Mapping_ShopPoint_ShopPointPropertyValue
- ShopPointSponsor
- Agent
- ShopNetStatus
- ShopNet
- ShopPointVisibilityType
- ShopPoint
- Trovaprodotti
- TrovaprodottiCulture
- Region
- Province
- City
- Picture
- Customer
- Mapping_Customer
- User
- UserUnregistered
- Wishlist
- Mapping_Wishlist_Product
- Selection
- Mapping_Selection_Product
- ProductThumbs
- History_Email
Popolamento Region/Province/City
Attualmente abbiamo importato i dati sporchi così come sono con la seguente query
INSERT INTO DesignbestCore.dbo.Region
SELECT Region.ID,
CASE
WHEN Region.CountryID = 3 THEN 1
WHEN Region.CountryID = 2 THEN 3
WHEN Region.CountryID = 4 THEN 4
WHEN Region.CountryID = 1000 THEN 2
END AS LanguageID,
Region.Coordinates,
Region.LocalizerCode,
RegionCulture.Region AS [Name],
LOWER(RegionCulture.SEORegion) AS SeoName
FROM Region
INNER JOIN RegionCulture ON Region.ID = RegionCulture.RegionID
INSERT INTO DesignbestCore.dbo.Province
SELECT Province.ID,
CASE
WHEN Province.CountryID = 3 THEN 1
WHEN Province.CountryID = 2 THEN 3
WHEN Province.CountryID = 4 THEN 4
WHEN Province.CountryID = 1000 THEN 2
END AS LocalizationID,
Province.Coordinates,
Province.ProvinceCode,
Province.RegionID,
ProvinceCulture.Province AS Name,
LOWER(ProvinceCulture.SEOProvince) AS SeoName
FROM Province
INNER JOIN ProvinceCulture ON Province.ID = ProvinceCulture.ProvinceID
INNER JOIN Region ON Province.RegionID = Region.ID
INSERT INTO DesignbestCore.dbo.City
SELECT City.ID,
CASE
WHEN City.CountryID = 3 THEN 1
WHEN City.CountryID = 2 THEN 3
WHEN City.CountryID = 4 THEN 4
WHEN City.CountryID = 1000 THEN 2
END AS LocalizationID,
City.ProvinceID,
City.City AS [Name],
LOWER(City.SeoCity) AS SeoName
FROM City
INNER JOIN Province ON Province.ID = City.ProvinceID
INNER JOIN Region ON Province.RegionID = Region.ID
Custom Properties
L'idea è quella di creare da una semplicissima struttura di tabelle
- ProductProperty
- ProductPropertyValue
- Mapping_Category_ProductProperty
- Mapping_Product_ProductPropertyValue
l'assegnazione di qualsiasi proprietà (stile, finitura, colori, decori, formati, proprietà di tipologia, designer, campi custom)
Per ognuna di queste custom property è possibile specificare
- Nome
- Nome SEO
- Valore
- Immagine (opzionale, gestita da
Pictures)
Stesso concetto su tabelle separate per gli ShopPoint
- ShopPointProperty
- ShopPointPropertyValue
- Mapping_ShopPoint_ShopPointPropertyValue
assegnazione delle proprietà come gli ShopPointServices
Per quanto riguarda gli ShopPointServices, purtroppo abbiamo ereditato una logica per la quale, se esiste il valore PropertyValue nel mapping, allora il negozio possiede quella Property. Di conseguenza, se il negozio possiede una certa Property e non specifica nessun suo valore, è necessario inserire un PropertyValue vuoto.
Schifezze
Controllare i valori delle custom properties perché il database è pieno di duplicati assegnati a prodotti diversi.
Ad esempio la ProductProperty Caratteristiche con SeoName Caratteristiche - Sedie c'è due volte con ID differenti.
Per rimediare si potrebbero assegnare tutti i prodotti ad un unico di questi ID e cancellare l'altro doppio.
Questa roba fa casino nel count dei prodotti nel telecomando
SELECT [Name],[SeoName], COUNT(SeoName) AS Duplic
FROM ProductPropertyValue
GROUP BY [Name], SeoName
ORDER BY Duplic DESC, [Name] ASC
ProductThumbs
Questa tabella purtroppo è necessaria in quanto i listing prodotti di una tipologia sono troppo lenti (tempo esecuz > 1s).
Una singola riga rappresenta un ProductThumbanil comprensivo di tutti i dati necessari a creare l'anteprima quadrata, titolo, ambiente, tipo manu e dati per creare i link.
Sarà tenuta aggiornata in tempo reale dalla backoffice (no task schedulati).
Tabelle escluse
Di seguito le tabelle che non riteniamo più utili:
ShopManufacturerExceptionShopContentExtra
Shop
ShopNet Casi Particolari
Attenzione che ogni SHOPNET deve avere una mail univoca altrimenti non viene caricato il Vendor su DOKAN (Wordpress vuole che le mail siano univoche per ogni utente).
Tutti i negozi ora appartengono obbligatoriamente ad una ShopNet Queste ShopNet in particolare:
- ShopNet Trovaprodotti Orfani Tutti i Trovaprodotti che non avevano una ShopNet. Hanno
Piva = '000000000000'. Ne viene creata una per ognuno. - ShopNet con PIVA nulla - Le vecchie ShopNet senza PIVA. Hanno
Piva = '000000000001' - ShopNet Anagrafiche - Contiene tutti gli ShopPoint di tipo != 0 che sono anagrafiche. Un padre per molti figli. Ha
Piva = '000000000003'. - ShopNet Estero - Tutti gli ShopPoint Esteri. Hanno
Piva = '000000000004'. Ne viene creata una per ognuno.
ShopFulltextAdditions
Gestione della ricerca full-text dei negozi che aggiunge ambienti, tipologie e produttori alle chiavi di ricerca del singolo negozio.
Sarà necessario reimplementare tutto il passaggio con il task notturno che genera le righe?
E-mail duplicate in ShopNet differenti
Attualmente ci sono dei casi di ShopNet che hanno il flag Enable_Outlet = 1 e la stessa email.
Questa situazione non va bene perché la sincronizzazione su Outlet Wordpress prevede che la mail sia univoca per ogni venditore (che corrisponde ad un user wp).
La backoffice, in caso di ShopNet Outlet Enabled, dovrà sempre controllare che la mail inserita non sia già presente.
Ecco un elenco dei casi scorretti presenti sulla nostra base di dati (DesignbestCore db):
SELECT MainMail, COUNT(MainMail) AS Quante
FROM ShopNet
WHERE Enable_Outlet = 1
GROUP BY MainMail
ORDER BY Quante DESC
Pictures
La gestione delle immagini sarà basata su quella di Nop.
| Picture | ||
|---|---|---|
| ID | int | ID della picture |
| EntityID | int | ID dell'entità |
| EntityKeyGroup | nvarchar(100) | Nome della Tabella di riferimento |
| EntityKey | nvarchar(100) | Formato dell'immagine desiderato |
| EntityValue | nvarchar(255) | Nome dell'immagine |
| DisplayOrder | int | Ordinamento |
Tutte le immagini saranno in un unico folder
product-<EntityID>-<ID>.jpg
bargain-<EntityID>-<ID>.jpg
manufacturer-<EntityID>-<ID>.jpg
shop-<EntityID>-<ID>.jpgQuesta soluzione è meno leggibile dall'umano ma molto più elastica nel caso in cui ci siano diversi cambiamenti di ordine, master/alternative (evita di dover rinominare l'immagine su disco).
Esempio Volendo trovare tutte le immagini relative ad uno shop si potrebbe usare la seguente query:
SELECT *
FROM Picture
WHERE EntityID = 15314 AND KeyGroup = 'Shop'
Avendo come risultato qualcosa di simile.
bla bla bla ....
Convenzioni
Per quanto riguarda i campi EntityGroup e EntityKey ecco cosa proponiamo
- ShopPoint
- cover
- logo
- gallery
- Product
- gallery
- square
- Manufacturer
- logo
- logo-square
- cover
- sponsored (bottone sponsor in HP)
- gallery
- Category
- ambient
- Trovaprodotti segue le stesse regole nelle tabelle _ext ma negli EntityValue cambia così
- gallery (prodotti a catalogo creati da cliente)
- productext-<context>
- logo
- manufacturerext-<context>
- gallery (prodotti a catalogo creati da cliente)
Entity Deepening - Approfondimenti delle entità
| EntityDeepening | ||
|---|---|---|
| ID | int | ID della picture |
| LanguageID | int | Lingua |
| EntityID | int | ID dell'entità |
| EntityKeyGroup | nvarchar(100) | Nome della Tabella di riferimento |
| EntityKey | nvarchar(100) | Formato dell'immagine desiderato |
| ExternalID | int | ID esterno |
| Link | nvacrchar(255) | Link esterno |
| Title | nvacrchar(255) | Link esterno |
| ShortDescription | nvacrchar(255) | Descrizione breve |
| MediaLink | nvacrchar(255) | Link ad un media |
| DisplayOrder | int | Ordinamento |
La tabella EntityDeepening rappresenta un calderone generico per poter assegnare ad una qualsiasi nostra entità (Manu, Shop, Product ecc) i seguenti valori:
- Id esterno
- Link esterno
- Titolo articolo
- Descrizione breve articolo
- Foto (facoltativa)
che rappresentano approfondimenti su altre piattaforme (es. Magazine).
Verrà utilizzata per Brand Channel (manu) e Progetti (manu e shop).
Di seguito le chiavi EntityGroup ed EntityKey:
- Manufacturer
- brandchannel
- project
- ShopNet
- project
Le selezioni
Utilizziamo il concetto di selezione per definire gruppi di prodotti (oppure negozi ecc) al fine di poterli richiamare in quei moduli che attualmente hanno una logica circostanziale spesso gestiti con xml.
In questo modo possiamo creare N selezioni tramite il backoffice da usare nei casi più svariati.
Importazione dati
Eseguire nell'ordine
- Reset_All_Tables (database
DesignbestCore) ~ 4 min - WM_CategorySynchCore
- WM_ProductSynchCore ~ 3 min
- Fare la chiamata API a
https://www.designbestoutlet.com/wp-json/designbest-outlet/v1/listallvendorscon Postman e piazzare il file json restituito inD:\Temp\Outlet-Vendors.jsonsulla macchinaBIANCANEVE - WM_ShopNetSynchCore
- WM_ProductPropertySynchCore (OCCHIO, prima di lanciarla controllare che non ci siano Designer con seoname duplicato su Designbest!)
- FullTextSearch, eseguire i comandi del paragrafo #Negozi nel database
DesignbestCore - WM_PicturesSynchCore (verificare aggiornamento path di XML BrandChannel su
D:\Temp) su BIANCANEVE e rinominare fisicamente le immagini degli ambienti aggiungendo PictureID generato al nome esbagno-14-217177 - WM_Nop_SyncCore (verificare i negozi nella
DesignbestCore.dbo.NopMapping_ShopNetsconfrontandoli con la vecchia) - WM_UsersCore
- WM_TpCustomSynchCore
- Cancellare tutte le immagini nella cartella
pictures - Immagini occasioni - Eseguire script Python tramite
D:\Programs\MigrazioneDB_DBCore\DesignbestBargainMigration.batsu ARIEL (~ 10 min). - Immagini cover shop - Eseguire script Python
D:\Programs\MigrazioneDB_DBCore\DesignbestShopCoverAltMigration.pysu ARIEL - Utility_ProductThumbsMerge (database
DesignbestCore) - Immagini fisiche - Eseguire la query SQL per generare il file batch che sposterà i file, database
DesignbestCore
SELECT
'IF EXIST "' + REPLACE(old_PicturePath, '/', '\') + '" (',
'xcopy /y "' + REPLACE(old_PicturePath, '/', '\') + '" ' + '"D:\WM3Resources\ImmaginiWM3\pictures\' + EntityValue + '-'+ CAST(EntityID AS VARCHAR(10)) + '-' + CAST(ID AS VARCHAR(10)) + '.jpg*"',
') ELSE ( echo ' + CAST(ID AS VARCHAR(10)) + ' BigPath >> missingimages.txt )'
FROM Picture
Update Width e Height delle Pictures - Eseguire script Python tramite.D:\Programs\python-CoreGetSetPicturesWidthHeight\main.pysu ARIEL (~ oo min)- Immagini selezioni TP - Eseguire script Python tramite
D:\Programs\MigrazioneDB_DBCore\DesignbestSelectionMigration.batsu ARIEL (~ 3 min). - Immagini fisiche selezioni - Eseguire la query SQL per generare il file batch che sposterà i file, database
DesignbestCore
SELECT
'IF EXIST "' + REPLACE(old_PicturePath, '/', '\') + '" (',
'xcopy /y "' + REPLACE(old_PicturePath, '/', '\') + '" ' + '"D:\WM3Resources\ImmaginiWM3\pictures\' + EntityValue + '-'+ CAST(EntityID AS VARCHAR(10)) + '-' + CAST(ID AS VARCHAR(10)) + '.jpg*"',
') ELSE ( echo ' + CAST(ID AS VARCHAR(10)) + ' BigPath >> missingimages2.txt )'
FROM Picture_Ext
WHERE old_PicturePath IS NOT NULL
- Update Width e Height delle Pictures delle Selezioni - Eseguire script Python tramite
D:\Programs\python-CoreGetSetPicturesWidthHeight\CoreGetSetWidthHeight.batsu ARIEL (~ oo min). - Rilanciare SP -> Utility_ProductThumbsMerge (database
DesignbestCore) - Rilanciare SP -> Utility_ProductThumbsMerge_Ext e FullText_Products_Update_Ext
DECLARE @TrovaprodottiID int
DECLARE cur3 CURSOR FOR
SELECT DISTINCT Context FROM DesignbestCore.dbo.Product_Ext
OPEN cur3;
FETCH NEXT FROM cur3 INTO @TrovaprodottiID
WHILE @@FETCH_STATUS = 0 BEGIN
EXEC DesignbestCore.dbo.Utility_ProductThumbsMerge_Ext @TrovaprodottiID, 1
EXEC DesignbestCore.dbo.FullText_Products_Update_Ext @TrovaprodottiID
FETCH NEXT FROM cur3 INTO @TrovaprodottiID
END
CLOSE cur3;
DEALLOCATE cur3;
- SU NOP (aggiornare il trigger della tabella Product)
USE [Designbest-Commerce]
GO
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
ALTER TRIGGER [dbo].[Product_ChangeQuantity]
ON [dbo].[Product]
AFTER UPDATE
AS
BEGIN
SET NOCOUNT ON;
DECLARE @OccNopID INT = 0, @NumPezziAggiornato INT;
IF UPDATE([StockQuantity])
BEGIN
SELECT @OccNopID = ProductBargainCore.NopID FROM Db_ProductBargain as ProductBargainCore
WHERE ProductBargainCore.NopID IN (
SELECT i.Id FROM inserted i
)
IF @OccNopID = 0 return;
SELECT @NumPezziAggiornato = i.StockQuantity FROM inserted i;
UPDATE Db_ProductBargain
SET Db_ProductBargain.Pieces = @NumPezziAggiornato
WHERE Db_ProductBargain.NopID = @OccNopID
PRINT 'TRIGGER [Product_ChangeQuantity] ESEGUITO e Aggiornato su TP'
END
ELSE
BEGIN
PRINT 'TRIGGER [Product_ChangeQuantity] ESEGUITO, ma nessuna modifica su TP'
END
END
- Aggiungere e mettere gli indici fulltext (sotto Storage) per le viste
FT_Shops_IT,FT_Shops_EN,FT_Shops_DEeFT_Shops_FR - Query di pulizia dati, database
DesignbestCore
-- Pulizia campo ausiliario per oldSelectionID
UPDATE Product SET [Weight] = 0
-- Pulizia campi sporchi TpApproved = 1 quando prodotto non visibile
UPDATE ProductBargain SET TpApproved = 0, OutletApproved = 0, CommerceApproved = 0, OutletToModerate = NULL, CommerceToModerate = NULL
FROM ProductBargain
INNER JOIN ProductCulture ON ProductBargain.ProductId = ProductCulture.ProductId
WHERE ProductCulture.Visible = 0 AND ProductCulture.LanguageId = 1
Operazione per Outlet WP, Nop Commerce e Lead manager
- Outlet Plugin - Usare il pulsante POST IMPORT SKU CHANGE per cambiare tutti gli SKU da
old_bargainIDa nuovoProductIDdi DesignbestCore. - Nop - Sql, copiare il trigger come specificato nell'ultimo punto del paragrafo precedente (verificare esistenza utente
wmusersu_DesignbestCore) - LM - Backuppare database
LeadManagercon il comando "Export Data-tier Application" in un filebacpac - LM - Modificare a mano il campo
category.codecon i nuovi id ambiente ai 23 record presenti che non iniziano con O - LM - Query per modificare il campo
product.codecon i nuovi id occasione, lanciare i risultati di queste due query come update su databaseLeadManager
-- Lead Manager - Adeguamento nuovi ID category e product (occasioni)
SELECT 'UPDATE category SET code = ''' + CAST(ID AS VARCHAR(10)) + ''' WHERE code = ''' + CAST(temp_old_id AS VARCHAR(10)) + ''' AND category = ''' + [Name] + ''''
FROM Category
WHERE CategoryLevel = 1
SELECT 'UPDATE product SET code = ''' + CAST(ProductId AS VARCHAR(10)) + ''' WHERE code = ''O' + CAST(old_BargainID AS VARCHAR(10)) + ''''
FROM ProductBargain
WHERE old_BargainID <> 0
-- category change in product
UPDATE product SET categoryID = 2 WHERE categoryID = 23
UPDATE product SET categoryID = 17 WHERE categoryID = 24
UPDATE product SET categoryID = 2 WHERE categoryID = 28
UPDATE product SET categoryID = 2 WHERE categoryID = 30
UPDATE product SET categoryID = 2 WHERE categoryID = 36
UPDATE product SET categoryID = 10 WHERE categoryID = 37
UPDATE product SET categoryID = 6 WHERE categoryID = 40
UPDATE product SET categoryID = 20 WHERE categoryID = 41
UPDATE product SET categoryID = 12 WHERE categoryID = 44
UPDATE product SET categoryID = 1 WHERE categoryID = 45
UPDATE product SET categoryID = 2 WHERE categoryID = 46
UPDATE product SET categoryID = 3 WHERE categoryID = 47
UPDATE product SET categoryID = 4 WHERE categoryID = 48
UPDATE product SET categoryID = 5 WHERE categoryID = 49
UPDATE product SET categoryID = 6 WHERE categoryID = 50
UPDATE product SET categoryID = 7 WHERE categoryID = 51
UPDATE product SET categoryID = 8 WHERE categoryID = 52
UPDATE product SET categoryID = 20 WHERE categoryID = 53
UPDATE product SET categoryID = 1 WHERE categoryID = 54
UPDATE product SET categoryID = 10 WHERE categoryID = 55
UPDATE product SET categoryID = 11 WHERE categoryID = 56
UPDATE product SET categoryID = 12 WHERE categoryID = 57
UPDATE product SET categoryID = 13 WHERE categoryID = 58
UPDATE product SET categoryID = 14 WHERE categoryID = 59
UPDATE product SET categoryID = 18 WHERE categoryID = 60
UPDATE product SET categoryID = 19 WHERE categoryID = 61
UPDATE product SET categoryID = 21 WHERE categoryID = 62
UPDATE product SET categoryID = 22 WHERE categoryID = 63
-- category change in repository
UPDATE repository SET categoryID = 2 WHERE categoryID = 23
UPDATE repository SET categoryID = 17 WHERE categoryID = 24
UPDATE repository SET categoryID = 2 WHERE categoryID = 28
UPDATE repository SET categoryID = 2 WHERE categoryID = 30
UPDATE repository SET categoryID = 2 WHERE categoryID = 36
UPDATE repository SET categoryID = 10 WHERE categoryID = 37
UPDATE repository SET categoryID = 6 WHERE categoryID = 40
UPDATE repository SET categoryID = 20 WHERE categoryID = 41
UPDATE repository SET categoryID = 12 WHERE categoryID = 44
UPDATE repository SET categoryID = 1 WHERE categoryID = 45
UPDATE repository SET categoryID = 2 WHERE categoryID = 46
UPDATE repository SET categoryID = 3 WHERE categoryID = 47
UPDATE repository SET categoryID = 4 WHERE categoryID = 48
UPDATE repository SET categoryID = 5 WHERE categoryID = 49
UPDATE repository SET categoryID = 6 WHERE categoryID = 50
UPDATE repository SET categoryID = 7 WHERE categoryID = 51
UPDATE repository SET categoryID = 8 WHERE categoryID = 52
UPDATE repository SET categoryID = 20 WHERE categoryID = 53
UPDATE repository SET categoryID = 1 WHERE categoryID = 54
UPDATE repository SET categoryID = 10 WHERE categoryID = 55
UPDATE repository SET categoryID = 11 WHERE categoryID = 56
UPDATE repository SET categoryID = 12 WHERE categoryID = 57
UPDATE repository SET categoryID = 13 WHERE categoryID = 58
UPDATE repository SET categoryID = 14 WHERE categoryID = 59
UPDATE repository SET categoryID = 18 WHERE categoryID = 60
UPDATE repository SET categoryID = 19 WHERE categoryID = 61
UPDATE repository SET categoryID = 21 WHERE categoryID = 62
UPDATE repository SET categoryID = 22 WHERE categoryID = 63
-- Tronchiamo config_company_category
TRUNCATE TABLE config_company_category
-- Cancelliamo le category outlet
DELETE FROM category WHERE categoryID >= 23
-- Ci inseriamo tutto di tutti
INSERT INTO config_company_category(companyID, categoryID)
SELECT DISTINCT company.companyID, category.categoryID
FROM category, company
ORDER BY company.companyID, category.categoryID
Eccezione 44334
La shop net di test, 44334, dopo l'import risulta "azzoppata". Bisogna mettere i record dei suoi Manufacturer Custom dentro al mapping:
-- Esempio....
INSERT INTO [dbo].[Mapping_ShopPoint_Manufacturer_Ext]([Context],[ShopPointID],[ManufacturerID],[DisplayOrder])
VALUES (44334,44334,696,100)
utilizzando gli ID generati dalla import nuova
Tabelle Pre-popolate
Queste tabelle sono statiche e non vengono toccate dall'importazione:
- Agent
- ShopNetStatus
- City
- Province
- Region
- Language
- Selection
- ContactRoles
- ManufacturerContractType
Cosa manca
L'importazione lascia vuote le tabelle:
- Mapping_Selection_ShopPoint
- ShopPointSponsor
SEO Title e Description
Le nuove tabelle ospitano i campi MetTitle e MetaDescription, nell'importazione vengono lasciati vuoti.
Questi dati li abbiamo, stanno nella MetaTagsHelper, dobbiamo successivamente pensare a come importarli nei campi giusti.
SEO Regole
Creata una tabella SeoRules culturizzata tramite LanguageId.
Full Text Search
La full text ha bisogno di tabelle con unica chiave primaria e i campi testuali sui quali lavorare.
Nel progetto precedente (WM5) utilizzavamo delle viste indicizzate, in questo non è più possibile farlo perché la struttura delle nuove tabelle implica delle self-join che per la fulltext non sono ammesse.
Non ci resta che optare per la creazione di tabelle apposite per la ricerca che dovranno essere mantenute aggiornate con qualche task schedulato.
Prodotti
Le tabelle implicate sono
FT_Products_ITFT_Products_ENFT_Products_FRFT_Products_DEFT_Products_IT_ExtFT_Products_EN_ExtFT_Products_FR_ExtFT_Products_DE_Ext
e vengono aggiornate (con MERGE) dalla SP FullText_Products_Update e dalla SP FullText_Products_Update_Ext (in caso di contesto TP)
Per effettuare una ricerca prodotti utilizzare la FullText_Products_Search oppure FullText_Products_Search_Ext (in caso di contesto TP)
Negozi
Qui rimaniamo col vecchio approccio delle viste indicizzate dato che non ci sono self-join al momento.
Script di creazione delle viste:
DROP VIEW IF EXISTS dbo.FT_Shops_IT
GO
DROP VIEW IF EXISTS dbo.FT_Shops_EN
GO
DROP VIEW IF EXISTS dbo.FT_Shops_FR
GO
DROP VIEW IF EXISTS dbo.FT_Shops_DE
GO
-- ITALIA
CREATE VIEW dbo.FT_Shops_IT WITH SCHEMABINDING
AS
SELECT
ShopPoint.ID,
ShopPoint.[Name],
ShopNet.[Name] AS ShopNetName,
LocDescription.[LocaleValue] AS [Description],
ShopPoint.Referente,
ShopPoint.[Address],
ShopPoint.Phone,
ShopPoint.Mail,
ShopPoint.BackofficeNotes,
Region.[Name] AS Region,
Province.[Name] AS Province,
City.[Name] AS City
FROM dbo.ShopPoint
INNER JOIN dbo.ShopNet ON ShopPoint.ShopNetID = ShopNet.ID
INNER JOIN dbo.City ON ShopPoint.CityID = City.ID
INNER JOIN dbo.Province ON City.ProvinceID = Province.ID
INNER JOIN dbo.Region ON Province.RegionID = Region.ID
INNER JOIN dbo.LocalizedProperty AS LocDescription ON ShopPoint.ID = LocDescription.EntityId AND LocDescription.LanguageId = 1 AND LocDescription.LocaleKeyGroup = 'ShopPoint' AND LocDescription.LocaleKey = 'Description'
WHERE ShopPoint.Visible = 1 AND ShopPoint.VisibilityTypeID = 0
GO
CREATE UNIQUE CLUSTERED INDEX UQ_ID
ON dbo.FT_Shops_IT(ID)
GO
-- WORLD
CREATE VIEW dbo.FT_Shops_EN WITH SCHEMABINDING
AS
SELECT
ShopPoint.ID,
ShopPoint.[Name],
ShopNet.[Name] AS ShopNetName,
LocDescription.[LocaleValue] AS [Description],
ShopPoint.Referente,
ShopPoint.[Address],
ShopPoint.Phone,
ShopPoint.Mail,
ShopPoint.BackofficeNotes,
Region.[Name] AS Region,
Province.[Name] AS Province,
City.[Name] AS City
FROM dbo.ShopPoint
INNER JOIN dbo.ShopNet ON ShopPoint.ShopNetID = ShopNet.ID
INNER JOIN dbo.City ON ShopPoint.CityID = City.ID
INNER JOIN dbo.Province ON City.ProvinceID = Province.ID
INNER JOIN dbo.Region ON Province.RegionID = Region.ID
INNER JOIN dbo.LocalizedProperty AS LocDescription ON ShopPoint.ID = LocDescription.EntityId AND LocDescription.LanguageId = 2 AND LocDescription.LocaleKeyGroup = 'ShopPoint' AND LocDescription.LocaleKey = 'Description'
WHERE ShopPoint.Visible = 1 AND ShopPoint.VisibilityTypeID = 0
GO
CREATE UNIQUE CLUSTERED INDEX UQ_ID
ON dbo.FT_Shops_EN(ID)
GO
-- FRANCIA
CREATE VIEW dbo.FT_Shops_FR WITH SCHEMABINDING
AS
SELECT
ShopPoint.ID,
ShopPoint.[Name],
ShopNet.[Name] AS ShopNetName,
LocDescription.[LocaleValue] AS [Description],
ShopPoint.Referente,
ShopPoint.[Address],
ShopPoint.Phone,
ShopPoint.Mail,
ShopPoint.BackofficeNotes,
Region.[Name] AS Region,
Province.[Name] AS Province,
City.[Name] AS City
FROM dbo.ShopPoint
INNER JOIN dbo.ShopNet ON ShopPoint.ShopNetID = ShopNet.ID
INNER JOIN dbo.City ON ShopPoint.CityID = City.ID
INNER JOIN dbo.Province ON City.ProvinceID = Province.ID
INNER JOIN dbo.Region ON Province.RegionID = Region.ID
INNER JOIN dbo.LocalizedProperty AS LocDescription ON ShopPoint.ID = LocDescription.EntityId AND LocDescription.LanguageId = 3 AND LocDescription.LocaleKeyGroup = 'ShopPoint' AND LocDescription.LocaleKey = 'Description'
WHERE ShopPoint.Visible = 1 AND ShopPoint.VisibilityTypeID = 0
GO
CREATE UNIQUE CLUSTERED INDEX UQ_ID
ON dbo.FT_Shops_FR(ID)
GO
-- GERMANIA
CREATE VIEW dbo.FT_Shops_DE WITH SCHEMABINDING
AS
SELECT
ShopPoint.ID,
ShopPoint.[Name],
ShopNet.[Name] AS ShopNetName,
LocDescription.[LocaleValue] AS [Description],
ShopPoint.Referente,
ShopPoint.[Address],
ShopPoint.Phone,
ShopPoint.Mail,
ShopPoint.BackofficeNotes,
Region.[Name] AS Region,
Province.[Name] AS Province,
City.[Name] AS City
FROM dbo.ShopPoint
INNER JOIN dbo.ShopNet ON ShopPoint.ShopNetID = ShopNet.ID
INNER JOIN dbo.City ON ShopPoint.CityID = City.ID
INNER JOIN dbo.Province ON City.ProvinceID = Province.ID
INNER JOIN dbo.Region ON Province.RegionID = Region.ID
INNER JOIN dbo.LocalizedProperty AS LocDescription ON ShopPoint.ID = LocDescription.EntityId AND LocDescription.LanguageId = 4 AND LocDescription.LocaleKeyGroup = 'ShopPoint' AND LocDescription.LocaleKey = 'Description'
WHERE ShopPoint.Visible = 1 AND ShopPoint.VisibilityTypeID = 0
GO
CREATE UNIQUE CLUSTERED INDEX UQ_ID
ON dbo.FT_Shops_DE(ID)
GO
Le viste implicate sono
FT_Shops_ITFT_Shops_ENFT_Shops_FRFT_Shops_DE
Per effettuare una ricerca negozi utilizzare la FullText_Shops_Search
Sul Server
È necessario installare .NET 7.0, la versione Hosting Bundle da https://dotnet.microsoft.com/en-us/download/dotnet/7.0
Il server non chiede riavvio.
Per verificare che il framework sia presente digitare in una console:
dotnet --list-runtimes
per vedere .NET 7
Progetto VS
Program.cs
Nel file Program.cs pregenerato aggiungere i seguenti concetti
Sessione
In un progetto Net.Core 6 la sessione parte disabilitata.
Per iniettare la sessione è necessario attivare un gestore della cache integrato (IDistributedCache) e la sessione stessa con le sue opzioni di configurazione
come da esempio
builder.Services.AddDistributedMemoryCache(); //L'implementazione IDistributedCache viene usata come archivio di backup per la sessione
builder.Services.AddSession(options => {
//options.IdleTimeout = TimeSpan.FromSeconds(10); // default 20 minuti
//options.Cookie.HttpOnly = true; // default true
options.Cookie.Name = ".Designbest.Session"; // nome del cookie di sessione
options.Cookie.IsEssential = true;
});
Dopodiché è necessario attivarla inserendo app.UseSession():
L' ordine del middleware è importante.
Chiamare UseSession dopo e UseRouting prima di MapRazorPages e MapDefaultControllerRoute
// ...
app.UseAuthorization();
app.UseSession(); // attivazione sessione
app.MapRazorPages();
app.Run();
HttpContextAccessor e HttpClient
Abilitare questi servizi
HttpContextAccessorpermette di accedere all' HttpContext da qualsiasi classe.HttpClientpermette di fare request.
builder.Services.AddHttpContextAccessor(); // per avere l'oggetto IHttpContextAccessor nelle classi
builder.Services.AddHttpClient(); // per avere l'oggetto IHttpClientFactory nelle classi
Services/Dipendenze
Implementare tutti i servizi bene separati utilizzando il pattern Interfaccia-Implementazione.
Per abilitarli nel progetto, segnalare interfaccia e implementazione come segue:
builder.Services.AddScoped<IDesignbestContext, DesignbestContext>();
builder.Services.AddScoped<IGeolocalization, MaxMindGeolocalization>();
Ci sono 3 diverse durate del servizio
- Temporaneo
builder.Services.AddTransient(..)
istanza normale che muore alla fine dello scope della funzione in cui viene chiamata - Con Ambito
builder.Services.AddScoped(..)
viene utilizzata la stessa istanza per tutta la durata della richiesta utente - Singleton
builder.Services.AddSingleton(...)
viene utilizzata la stessa istanza finche IIS non viene stoppato
Javascript
Tutti i moduli, le funzioni e gli eventi del sito sono gestiti dai nostri script che non dipendono da terze parti (tantomeno da jQuery che per i dispositivi mobile è solo un rallentamento).
Sfruttiamo le ultime funzioni standardizzate in ECMASCRIPT 6, con le definizioni di classi, metodi, membri di classe e chiamate asincrone.
Il cosiddetto thread principale prevede un bundle minificato delle nostre risorse principali.
Compilazione a runtime
Abilitare la compilazione a runtime solo in ambiente di sviluppo.
- Scaricare il pacchetto nuget
Microsoft.AspNetCore.Mvc.Razor.RuntimeCompilation - Aggiungere il seguente codice al Program.cs
if (builder.Environment.IsDevelopment()) {
builder.Services.AddRazorPages().AddRazorRuntimeCompilation();
} else {
builder.Services.AddRazorPages();
}
Problema CopyRefAssembliesToPublishDirectory
Se dopo aver attivato la compilazione a Runtime il progetto dà un errore che parla di
CopyRefAssembliesToPublishDirectory
il problema potrebbe essere che dalle viste è stata fatta una @inject di un Service del quale non è stata specificata la @using all'interno di /Pages/_ViewImports.cshtml.
Mi è successo con IConfiguration, ho dovuto aggiungere questa riga
@using Microsoft.Extensions.Configuration
Environment - Development, Staging, Production
Per decidere con quale environment la web app deve essere pubblicata è necessario editare manualmente il publish profile aggiungendo la seguente
<Project>
<PropertyGroup>
<!-- Altre direttive -->
<EnvironmentName>Staging</EnvironmentName>
</PropertyGroup>
</Project>
I valori consentiti sono
- Production
- Staging
- Development - L'unico che permette la visualizzazione degli errori