Référence standard

mail@pastecode.io avatar
unknown
plain_text
3 years ago
697 B
4
Indexable
Never
public function referenceStandardProduct($product)
{
    return str_replace(' ', '-',
            formatCollection($product[3]) .
            '_' . formatDimension($product[8]) .
            '_' . trim($product[4])
    );
}

public function formatCollection($collection) 
{
    $collection = trim($collection);
    $collection = strtolower($collection);
    $collection = str_replace('*', '', $collection);
    $collection = str_replace(' ', '-', $collection);
    return $collection;
}

public function formatDimension($dimension) 
{
    $dimension = trim($dimension);
    $dimension = str_replace(' ', '', $dimension);
    $dimension = str_replace('X', 'x', $dimension);
    return $dimension;
}