72 lines
2.2 KiB
PHP
72 lines
2.2 KiB
PHP
<?php
|
|
$file = file_get_contents('https://sklep744813.shoparena.pl/console/integration/execute/name/GoogleProductSearch/lang/pl_PL');
|
|
$xml = new SimpleXMLElement($file);
|
|
|
|
for ($i = 0; $i < count($xml->entry); $i++) {
|
|
// Odnalezienie elementu shipping dla aktualnego item
|
|
$shipping = $xml->entry[$i]->shipping;
|
|
if ($shipping) {
|
|
// Dodanie nowego elementu g:max_transit_time do shipping
|
|
$shipping->addChild('g:max_transit_time', '2'); // Możesz zastąpić 'TwojaWartość' odpowiednią wartością
|
|
$shipping->addChild('g:max_handling_time', '1'); // Możesz zastąpić 'TwojaWartość' odpowiednią wartością
|
|
}
|
|
}
|
|
|
|
$xml->asXml('feed-main.xml');
|
|
echo '<p>wygenerowano https://cdn.projectpro.pl/ibramakeup/feed-main.xml</p>';
|
|
|
|
// Wczytaj plik XML
|
|
$xmlString = file_get_contents('https://sklep744813.shoparena.pl/console/integration/execute/name/GoogleProductSearch/lang/pl_PL');
|
|
$xml = new SimpleXMLElement( $xmlString );
|
|
|
|
// Nazwy elementów do usunięcia
|
|
$elementsToRemove = [
|
|
'description',
|
|
'g:condition',
|
|
'g:availability',
|
|
'g:price',
|
|
'g:sale_price',
|
|
'g:sale_price_effective_date',
|
|
'g:shipping_weight',
|
|
'g:shipping',
|
|
];
|
|
|
|
// Namespace dla elementów 'g'
|
|
$namespaces = $xml->getNamespaces(true);
|
|
$gNamespace = $namespaces['g'];
|
|
|
|
// Pobierz wszystkie elementy entry
|
|
foreach ($xml->entry as $entry)
|
|
{
|
|
foreach ($elementsToRemove as $elementName)
|
|
{
|
|
$elementParts = explode(':', $elementName);
|
|
if (count($elementParts) == 2)
|
|
{
|
|
$prefix = $elementParts[0];
|
|
$localName = $elementParts[1];
|
|
$elements = $entry->children($namespaces[$prefix])->$localName;
|
|
foreach ($elements as $element)
|
|
{
|
|
// Usuń element z przestrzenią nazw
|
|
$domElement = dom_import_simplexml($element);
|
|
$domElement->parentNode->removeChild($domElement);
|
|
}
|
|
}
|
|
else
|
|
{
|
|
// Usuń element bez przestrzeni nazw
|
|
$elements = $entry->$elementName;
|
|
foreach ($elements as $element)
|
|
{
|
|
$domElement = dom_import_simplexml($element);
|
|
$domElement->parentNode->removeChild($domElement);
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
// Zapisz zmodyfikowany XML do nowego pliku
|
|
$xml->asXML( 'feed-zaufane.xml' );
|
|
echo '<p>wygenerowano https://cdn.projectpro.pl/ibramakeup/feed-zaufane.xml</p>';
|