本文整理匯總了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()];
}