Commit d2e50a21 authored by gbyte.co's avatar gbyte.co

Support commerce products

parent f33f00d3
......@@ -131,6 +131,10 @@ function simple_sitemap_entity_form_submit($form, &$form_state) {
$sitemap = \Drupal::service('simple_sitemap.generator');
$f = $form['#simple_sitemap'];
$values = $form_state->getValues();
// Fix for values appearing in a sub array on a commerce product entity.
if (isset($values['simple_sitemap'])) {
$values = $values['simple_sitemap'];
}
// Get current entity type sitemap settings.
$entity_types = $sitemap->getConfig('entity_types');
......
......@@ -133,7 +133,8 @@ class Form {
public static function valuesChanged($form, $form_state) {
$values = $form_state->getValues();
foreach (array('simple_sitemap_index_content', 'simple_sitemap_priority', 'simple_sitemap_regenerate_now') as $field_name) {
if ($values[$field_name] != $form['simple_sitemap'][$field_name]['#default_value']) {
if (isset($values['simple_sitemap'][$field_name]) && $values['simple_sitemap'][$field_name] != $form['simple_sitemap'][$field_name]['#default_value']
|| isset($values[$field_name]) && $values[$field_name] != $form['simple_sitemap'][$field_name]['#default_value']) { // Fix for values appearing in a sub array on a commerce product entity.
return TRUE;
}
}
......
<?php
/**
* @file
* Contains \Drupal\simple_sitemap\Plugin\LinkGenerator\CommerceProductType.
*
* Plugin for commerce product entity link generation.
*/
namespace Drupal\simple_sitemap\Plugin\LinkGenerator;
use Drupal\simple_sitemap\Annotation\LinkGenerator;
use Drupal\simple_sitemap\LinkGeneratorBase;
/**
* CommerceProductType class.
*
* @LinkGenerator(
* id = "commerce_product_type"
* )
*/
class CommerceProductType extends LinkGeneratorBase {
/**
* {@inheritdoc}
*/
public function getInfo() {
return array(
'field_info' => array(
'entity_id' => 'product_id',
'lastmod' => 'changed',
),
'path_info' => array(
'route_name' => 'entity.commerce_product.canonical',
'entity_type' => 'commerce_product',
)
);
}
/**
* {@inheritdoc}
*/
public function getQuery($bundle) {
return $this->database->select('commerce_product_field_data', 'p')
->fields('p', array('product_id', 'changed'))
->condition('type', $bundle)
->condition('status', 1);
}
}
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment