本文整理汇总了PHP中Magento\Catalog\Model\Product::getPosition方法的典型用法代码示例。如果您正苦于以下问题:PHP Product::getPosition方法的具体用法?PHP Product::getPosition怎么用?PHP Product::getPosition使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Magento\Catalog\Model\Product
的用法示例。
在下文中一共展示了Product::getPosition方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: assertProductInfo
/**
* @param \Magento\Catalog\Model\Product $product
*/
private function assertProductInfo($product)
{
$data = [1 => ['sku' => 'simple', 'name' => 'Simple Product', 'price' => '10', 'qty' => '1', 'position' => '1'], 21 => ['sku' => 'virtual-product', 'name' => 'Virtual Product', 'price' => '10', 'qty' => '2', 'position' => '2']];
$productId = $product->getId();
$this->assertEquals($data[$productId]['sku'], $product->getSku());
$this->assertEquals($data[$productId]['name'], $product->getName());
$this->assertEquals($data[$productId]['price'], $product->getPrice());
$this->assertEquals($data[$productId]['qty'], $product->getQty());
$this->assertEquals($data[$productId]['position'], $product->getPosition());
}
示例2: shakeSelections
/**
* Sort selections method for usort function
* Sort selections by option position, selection position and selection id
*
* @param \Magento\Catalog\Model\Product $firstItem
* @param \Magento\Catalog\Model\Product $secondItem
* @return int
*/
public function shakeSelections($firstItem, $secondItem)
{
$aPosition = [$firstItem->getOption()->getPosition(), $firstItem->getOptionId(), $firstItem->getPosition(), $firstItem->getSelectionId()];
$bPosition = [$secondItem->getOption()->getPosition(), $secondItem->getOptionId(), $secondItem->getPosition(), $secondItem->getSelectionId()];
if ($aPosition == $bPosition) {
return 0;
} else {
return $aPosition < $bPosition ? -1 : 1;
}
}
示例3: convert
/**
* {@inheritdoc}
*/
public function convert(\Magento\Catalog\Model\Product $product)
{
return [ProductLink::TYPE => $product->getTypeId(), ProductLink::SKU => $product->getSku(), ProductLink::POSITION => $product->getPosition()];
}
示例4: convert
/**
* {@inheritdoc}
*/
public function convert(\Magento\Catalog\Model\Product $product)
{
return [ProductLink::TYPE => $product->getTypeId(), ProductLink::SKU => $product->getSku(), ProductLink::POSITION => $product->getPosition(), ProductLink::CUSTOM_ATTRIBUTES_KEY => [[AttributeValue::ATTRIBUTE_CODE => 'qty', AttributeValue::VALUE => $product->getQty()]]];
}
示例5: convert
/**
* {@inheritdoc}
*/
public function convert(\Magento\Catalog\Model\Product $product)
{
return ['type' => $product->getTypeId(), 'sku' => $product->getSku(), 'position' => $product->getPosition(), 'custom_attributes' => [['attribute_code' => 'qty', 'value' => $product->getQty()]]];
}
示例6: convert
/**
* {@inheritdoc}
*/
public function convert(\Magento\Catalog\Model\Product $product)
{
return ['type' => $product->getTypeId(), 'sku' => $product->getSku(), 'position' => $product->getPosition()];
}