Jump to content

Не отображаются связанные товары, если у них нет цены


Recommended Posts

Добрый день. Не выводятся связанные товары, если у них не стоит цена. Как выводить все связанные товары независимо от наличия цены?

Правил файл ProductViev.php

// Связанные товары
$related_ids = array();
$related_products = array();
foreach ( $this->products->get_related_products( $product->id ) as $p ) {
	$related_ids[] = $p->related_id;
	$related_products[ $p->related_id ] = null;
}
if ( !empty( $related_ids ) ) {
	foreach ( $this->products->get_products( array( 'id' => $related_ids, 'in_stock' => 1, 'visible' => 1 ) ) as $p )
		$related_products[ $p->id ] = $p;

	$related_products_images = $this->products->get_images( array( 'product_id' => array_keys( $related_products ) ) );
	foreach ( $related_products_images as $related_product_image )
		if ( isset( $related_products[ $related_product_image->product_id ] ) )
			$related_products[ $related_product_image->product_id ]->images[] = $related_product_image;
	$related_products_variants = $this->variants->get_variants( array( 'product_id' => array_keys( $related_products ), 'in_stock' => 1 ) );
	foreach ( $related_products_variants as $related_product_variant ) {
		if ( isset( $related_products[ $related_product_variant->product_id ] ) ) {
			$related_products[ $related_product_variant->product_id ]->variants[] = $related_product_variant;
		}
	}
	foreach ( $related_products as $id => $r ) {
		if ( is_object( $r ) ) {
			$r->image = & $r->images[ 0 ];
			$r->variant = & $r->variants[ 0 ];
		} else {
			unset( $related_products[ $id ] );
		}
	}
	$this->design->assign( 'related_products', $related_products );
}

Если менять 'in_stock' => 1 на 'in_stock' => 0, то выводятся наоборот связанные товары без цен, а с ценами не выводятся. 

Link to post
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Loading...
×
×
  • Create New...